Skip to content

Create repository

POST /api/v5/orgs/{org}/repos

This endpoint creates a new repository in the specified organization. It supports code, model, dataset, and other repository types, lets you set public or private visibility, and supports configuring the default branch, initializing the README, and importing an external project.

Access token support

  • AtomGit user access tokens (AtomGit user access tokens)

Anonymous access

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
org path string Yes The organization path (path/login)
access_token query string Yes User authorization code

Request Body:

The request body is in application/json format. The fields are defined as follows:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "description": "Repository name",
      "type": "string"
    },
    "description": {
      "description": "Repository description",
      "type": "string"
    },
    "homepage": {
      "description": "Homepage",
      "type": "string"
    },
    "has_issues": {
      "description": "Whether issues are allowed. Defaults to allowed (true).",
      "type": "boolean",
      "default": true
    },
    "has_wiki": {
      "description": "Whether Wiki is provided. Defaults to provided (true).",
      "type": "boolean",
      "default": true
    },
    "can_comment": {
      "description": "Whether users can comment on the repository. Defaults to allowed (true).",
      "type": "boolean",
      "default": true
    },
    "public": {
      "description": "Repository open source type: 0 (private), 1 (public)",
      "type": "integer",
      "enum": [0, 1]
    },
    "auto_init": {
      "description": "When true, initializes the repository with a README. Defaults to 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"
    },
    "default_branch": {
      "description": "Default branch name when initializing the project. Defaults to main.",
      "type": "string",
      "default": "main"
    },
    "import_url": {
      "description": "Git URL of the project to import. Only one of import_url and project_template can be provided.",
      "type": "string"
    },
    "project_template": {
      "description": "Path of the template project. Only one of import_url and project_template can be provided.",
      "type": "string"
    },
    "repository_type": {
      "description": "Repository type: code: code repository, model: model repository, dataset: dataset repository, space: space. Defaults to code.",
      "type": "string",
      "enum": ["code", "model", "dataset", "space"],
      "default": "code"
    }
  },
  "required": ["name"]
}

Note: The request parameter public is an integer (0 private / 1 public). The private / public fields in the response are returned as booleans in the example; they have the same meaning and differ only in representation.

Response parameters

Field Type Always returned Nullable Description
id integer Yes No Repository ID
full_name string Yes No Repository full name (namespace path/repository path)
human_name string Yes No Human-readable repository name
url string Yes No Repository API URL
path string Yes No Repository path
name string Yes No Repository name
description string Yes Yes Repository description; may be null
private integer Yes Yes Whether the repository is private (0/1; may be returned as a boolean in the example); may be null
public integer Yes Yes Whether the repository is public (0/1; may be returned as a boolean in the example); may be null
namespace object Yes Yes Information about the namespace (organization/user) the repository belongs to
visibility string Yes Yes Repository visibility; may be null
homepage string Yes Yes Repository homepage; may be null

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 Yes Development mode; may be null
namespace.cell string Yes Yes Namespace cell; may be null
namespace.kind string Yes Yes Namespace kind (e.g. group); may be null
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 integer Yes Yes Whether file control is enabled (may be returned as a boolean in the example); may be null
namespace.region string No Yes Region; subject to the actual response
namespace.parent_id integer No Yes Parent namespace ID; subject to the actual response
namespace.owner_id integer No Yes Namespace owner ID; subject to the actual response

Note: The actual response may also contain nullable fields such as empty_repo, starred, owner, creator, forked_from_project, item_type, and main_repository_language (all null in the example). Refer to the actual response.

Error responses

400 Invalid parameters

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

401 Unauthenticated

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

Note: The error response field names (error / message / field) are subject to the actual backend response.

HTTP response status codes

Status code Description
200 Success (OK)
400 Invalid parameters (Bad request)
401 Authentication required (Requires authentication)
403 Forbidden
404 Not found
429 Too many requests; rate limit triggered
500 Internal system error

Request example

Parameter notes

Placeholder notes in the examples:

Replace <org> with the organization path (path/login); replace <token> with your AtomGit user access token.

cURL

curl -X POST 'https://api.atomgit.com/api/v5/orgs/<org>/repos?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
    "name": "my-repo",
    "description": "Repository description",
    "has_issues": true,
    "has_wiki": true,
    "can_comment": true,
    "public": 1,
    "auto_init": true,
    "gitignore_template": "Java",
    "license_template": "MIT",
    "path": "my-repo",
    "default_branch": "main",
    "repository_type": "code"
  }'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/orgs/<org>/repos?access_token=<token>", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json",
  },
  body: JSON.stringify({
    name: "my-repo",
    description: "Repository description",
    has_issues: true,
    has_wiki: true,
    can_comment: true,
    public: 1,
    auto_init: true,
    gitignore_template: "Java",
    license_template: "MIT",
    path: "my-repo",
    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/orgs/<org>/repos",
    params={"access_token": "<token>"},
    json={
        "name": "my-repo",
        "description": "Repository description",
        "has_issues": True,
        "has_wiki": True,
        "can_comment": True,
        "public": 1,
        "auto_init": True,
        "gitignore_template": "Java",
        "license_template": "MIT",
        "path": "my-repo",
        "default_branch": "main",
        "repository_type": "code",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "id": 34171993,
  "full_name": "daming_1/test_create_project_2",
  "human_name": "daming/test_create_project_2",
  "url": "https://api.atomgit.com/api/v5/repos/daming_1/test_create_project_2",
  "path": "test_create_project_2",
  "name": "test_create_project_2",
  "description": "Description",
  "private": false,
  "public": true,
  "namespace": {
    "id": 74962,
    "name": "group1111",
    "path": "group11111",
    "develop_mode": "normal",
    "region": null,
    "cell": "default",
    "kind": "group",
    "full_path": "group11111",
    "full_name": "group1111",
    "parent_id": null,
    "visibility_level": 20,
    "enable_file_control": false,
    "owner_id": null
  },
  "empty_repo": null,
  "starred": null,
  "visibility": "public",
  "owner": null,
  "creator": null,
  "forked_from_project": null,
  "item_type": null,
  "main_repository_language": null,
  "homepage": "http://www.baidi.com"
}

Error codes

Error code Description
400 Invalid parameters or the request cannot be parsed
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
403 Forbidden
404 The requested path does not exist
405 Request method not supported
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