Skip to content

Create a personal project repository

POST /api/v5/user/repos

Call this endpoint to create a personal project repository.

Supported access tokens

  • AtomGit user access token (AtomGit user access tokens)

Anonymous access

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
access_token query string Yes User authorization code

Request Body:

The request body is in JSON format; the fields are described below:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "description": "Repository name",
      "type": "string"
    },
    "description": {
      "description": "Repository description",
      "type": "string"
    },
    "has_issues": {
      "description": "Whether issues can be submitted; default: allowed (true)",
      "type": "boolean",
      "default": true
    },
    "has_wiki": {
      "description": "Whether the Wiki is provided; default: provided (true)",
      "type": "boolean",
      "default": true
    },
    "can_comment": {
      "description": "Whether users can comment on the repository; default: allowed (true)",
      "type": "boolean",
      "default": true
    },
    "auto_init": {
      "description": "When true, initialize the repository with a README; default: not initialized (false)",
      "type": "boolean",
      "default": false
    },
    "gitignore_template": {
      "description": "Git Ignore template",
      "type": "string"
    },
    "license_template": {
      "description": "License template",
      "type": "string"
    },
    "path": {
      "description": "Repository path",
      "type": "string"
    },
    "private": {
      "description": "Whether the repository is private",
      "type": "boolean"
    },
    "default_branch": {
      "description": "Default branch name when initializing the project; default: main",
      "type": "string",
      "default": "main"
    },
    "import_url": {
      "description": "Git URL of the project to import; mutually exclusive with project_template, so only one can be passed",
      "type": "string"
    },
    "project_template": {
      "description": "Path of the template project; mutually exclusive with import_url, so only one can be passed",
      "type": "string"
    },
    "repository_type": {
      "description": "Repository type: code (code repository), model (model repository), dataset (dataset repository), space (Space repository). Default: code",
      "type": "string",
      "enum": ["code", "model", "dataset", "space"],
      "default": "code"
    }
  },
  "required": ["name"]
}

Response parameters

Field Type Always returned Nullable Description
id integer Yes No Repository ID
full_name string Yes No Repository full name (owner/repository name)
human_name string Yes No Repository readable name (owner / repository name)
url string Yes No Repository API URL
namespace object Yes No Namespace information
path string Yes No Repository path
name string Yes No Repository name
description string Yes Yes Repository description; can be empty
private boolean Yes No Whether the repository is private
public boolean Yes No Whether the repository is public
visibility string Yes No Visibility (e.g. private / public)

namespace object

Field Type Always returned Nullable Description
namespace.id integer Yes No Namespace ID
namespace.name string Yes No Namespace name
namespace.path string Yes No Namespace path
namespace.develop_mode string Yes No Development mode (e.g. normal)
namespace.kind string Yes No Namespace type (e.g. user)
namespace.full_path string Yes No Namespace full path
namespace.full_name string Yes No Namespace full name
namespace.visibility_level integer Yes No Visibility level
namespace.enable_file_control boolean Yes No Whether file permission control is enabled
namespace.owner_id integer Yes No Owner ID

Error response

The following are common failure response examples. The actual error field names returned by the backend take precedence.

400 Invalid parameters

{
  "error": "invalid_request",
  "message": "Parameter name cannot be empty",
  "field": "name"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

HTTP status codes

Status code Description
200 Success (OK)
400 Invalid parameters or unparseable request
401 Requires authentication
403 Forbidden
404 Request path does not exist
500 Internal system error

Request example

Parameter notes

In the examples, <token> is where you put your AtomGit user access token; name is the required repository name, and all other request body fields are optional. Keep the request parameters and request body fields consistent with the descriptions above; copying them as-is produces a successful call.

cURL

curl -X POST 'https://api.atomgit.com/api/v5/user/repos?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
    "name": "my-project",
    "path": "my-project",
    "description": "My first repository",
    "private": false,
    "auto_init": true,
    "default_branch": "main",
    "has_issues": true,
    "has_wiki": true,
    "can_comment": true,
    "repository_type": "code"
  }'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/user/repos?access_token=<token>", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json",
  },
  body: JSON.stringify({
    name: "my-project",
    path: "my-project",
    description: "My first repository",
    private: false,
    auto_init: true,
    default_branch: "main",
    repository_type: "code",
  }),
});

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.post(
    "https://api.atomgit.com/api/v5/user/repos",
    params={"access_token": "<token>"},
    headers={"Content-Type": "application/json", "Accept": "application/json"},
    json={
        "name": "my-project",
        "path": "my-project",
        "description": "My first repository",
        "private": False,
        "auto_init": True,
        "default_branch": "main",
        "repository_type": "code",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "id": 4106383,
  "full_name": "dengmengmian/wunian-prj",
  "human_name": "dengmengmian / wunian-prj",
  "url": "https://api.atomgit.com/api/v5/user/repos",
  "namespace": {
    "id": 199940,
    "name": "dengmengmian",
    "path": "dengmengmian",
    "develop_mode": "normal",
    "kind": "user",
    "full_path": "dengmengmian",
    "full_name": "dengmengmian",
    "visibility_level": 20,
    "enable_file_control": false,
    "owner_id": 268
  },
  "path": "wunian-prj",
  "name": "wunian-prj",
  "description": "wunian-prj",
  "private": true,
  "public": false,
  "visibility": "private"
}

Error codes

Error code Description
400 Invalid parameters or unparseable request
401 Unauthenticated or invalid credentials (missing or invalid access token)
403 Forbidden
404 Request path does not exist
429 Too many requests; rate limit triggered
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc