Create issue¶
POST /api/v5/repos/{owner}/issues
Call this endpoint to create an issue in the specified repository.
Access token support¶
- AtomGit user access token (AtomGit user access tokens)
Anonymous access¶
This endpoint does not allow anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | Address path of the namespace that owns the repository (the address path of an organization or an individual) |
access_token |
query | string | Yes | User authorization code |
Request Body:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"repo": {
"description": "Repository path",
"type": "string"
},
"title": {
"description": "Issue title",
"type": "string"
},
"body": {
"description": "Issue description",
"type": "string"
},
"assignee": {
"description": "Username of the issue assignee; separate multiple values with commas",
"type": "string"
},
"milestone": {
"description": "Milestone number",
"type": "integer"
},
"labels": {
"description": "Comma-separated labels; each name must be 2-20 characters long and contain no special characters, for example: bug,performance",
"type": "string"
},
"security_hole": {
"description": "Whether this is a private issue (defaults to false)",
"type": "string"
},
"template_path": {
"description": "Issue template path. Project templates support files in the .gitcode, .github, and .gitee directories; organization templates support only files in the .gitcode directory of a .gitcode project",
"type": "string"
},
"issue_type": {
"description": "Issue type (supported in the enterprise edition); the value must match the settings in the enterprise issue advanced features",
"type": "string"
},
"issue_severity": {
"description": "Issue priority (supported in the enterprise edition); the value must match the settings in the enterprise issue advanced features",
"type": "string"
},
"custom_fields": {
"description": "Custom field information (supported in the enterprise edition)",
"type": "array",
"items": {
"type": "object",
"properties": {
"field_name": {
"description": "Field name",
"type": "string"
},
"field_values": {
"description": "Array of field values",
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
},
"required": ["repo", "title", "body"]
}
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
integer | Yes | No | ID of the issue |
html_url |
string | Yes | No | HTML address of the issue |
number |
integer | Yes | No | Issue number |
state |
string | Yes | No | Issue state, such as opened |
title |
string | Yes | No | Issue title |
body |
string | Yes | No | Issue description |
user |
object | Yes | No | Information about the user who created the issue |
assignee |
object | No | Yes | Information about the issue assignee; may be null |
repository |
object | Yes | No | Information about the repository the issue belongs to |
created_at |
string | Yes | No | Creation time |
updated_at |
string | Yes | No | Update time |
finished_at |
string | No | Yes | Completion time; may be null |
labels |
array | Yes | Yes | List of labels; may be null |
stage |
string | Yes | Yes | Stage of the issue |
severity |
string | Yes | Yes | Issue priority (severity) |
custom_fields |
array | No | Yes | Custom field information |
user object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
user.avatar_url |
string | Yes | No | User avatar address |
user.events_url |
string | No | Yes | Events address; may be null |
user.followers_url |
string | No | Yes | Followers address; may be null |
user.following_url |
string | No | Yes | Following address; may be null |
user.gists_url |
string | No | Yes | Gists address; may be null |
user.html_url |
string | Yes | No | User homepage address |
user.id |
string | Yes | No | User ID |
user.login |
string | Yes | No | Login name |
user.member_role |
string | No | Yes | Member role; may be null |
user.name |
string | Yes | No | User nickname |
user.organizations_url |
string | No | Yes | Organizations address; may be null |
user.received_events_url |
string | No | Yes | Received events address; may be null |
user.remark |
string | No | Yes | Remark; may be null |
user.repos_url |
string | No | Yes | Repository list address; may be null |
user.starred_url |
string | No | Yes | Starred address; may be null |
user.subscriptions_url |
string | No | Yes | Subscriptions address; may be null |
user.type |
string | No | Yes | User type; may be null |
user.url |
string | No | Yes | User address; may be null |
repository object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
repository.id |
integer | Yes | No | Repository ID |
repository.full_name |
string | Yes | No | Full repository name (such as owner/repo) |
repository.path |
string | Yes | No | Repository path |
repository.name |
string | Yes | No | Repository name |
repository.description |
string | Yes | Yes | Repository description |
repository.created_at |
string | Yes | No | Repository creation time |
repository.updated_at |
string | Yes | No | Repository update time |
labels object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
labels[].id |
integer | Yes | No | Label ID |
labels[].name |
string | Yes | No | Label name |
labels[].color |
string | Yes | No | Label color |
labels[].created_at |
string | Yes | No | Label creation time |
labels[].updated_at |
string | Yes | No | Label update time |
custom_fields object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
custom_fields[].field_name |
string | Yes | No | Custom field name |
custom_fields[].field_type |
string | Yes | No | Type of the custom field. Enum: text_single (single-line text), text_multi (multi-line text), integer (integer), decimal (decimal), date (date), select_single (single-select dropdown), select_multi (multi-select dropdown), member_single (single member), member_multi (multiple members) |
custom_fields[].field_visibility |
string | Yes | No | Visibility: 0 visible to administrators only, 1 visible to everyone |
custom_fields[].field_values |
string[] | Yes | No | Values of the custom field |
Error responses¶
This endpoint may return the following error responses when parameters are invalid or the request is unauthenticated. The actual error field names returned by the backend take precedence.
400 Parameter error
401 Unauthenticated
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Parameter error (Bad request) |
401 |
Requires authentication (Requires authentication) |
403 |
Forbidden (Forbidden) |
404 |
Resource not found (Not found) |
Request example¶
Parameter notes¶
The following examples can be copied and used directly: replace <owner> with the address path of the namespace that owns the repository (the address path of an organization or an individual); replace <repo> with the repository path (the path of the repository under the namespace corresponding to owner); replace <token> with your AtomGit user access token. Besides the required fields (repo, title, body), the examples also show commonly used optional fields.
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/issues?access_token=<token>' \
-H 'Content-Type: application/json' \
-d '{
"repo": "<repo>",
"title": "<issue title>",
"body": "<issue description>",
"assignee": "user1,user2",
"milestone": 3,
"labels": "bug,performance",
"security_hole": "false"
}'
JavaScript¶
// Native fetch (Node.js 18+ / browsers)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/issues?access_token=<token>", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
repo: "<repo>",
title: "<issue title>",
body: "<issue description>",
assignee: "user1,user2",
labels: "bug,performance",
}),
});
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/repos/<owner>/issues",
params={"access_token": "<token>"},
json={
"repo": "<repo>",
"title": "<issue title>",
"body": "<issue description>",
"assignee": "user1,user2",
"labels": "bug,performance",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
{
"id": 152642,
"html_url": "https://api.atomgit.com/dengmengmian/test01/issues/15",
"number": 15,
"state": "opened",
"title": "Half-month report",
"body": "This is a sample issue body used for the response example.",
"user": {
"avatar_url": "https://api.atomgit.com/avatars/dengmengmian.png",
"html_url": "https://api.atomgit.com/dengmengmian",
"id": "661ce4eab470b1430d456154",
"login": "dengmengmian",
"name": "Ma Fan_"
},
"assignee": null,
"repository": {
"id": 152642,
"full_name": "dengmengmian/test01",
"path": "test01",
"name": "test01",
"description": "",
"created_at": "2024-04-18T14:35:15.479+08:00",
"updated_at": "2024-04-18T14:35:15.479+08:00"
},
"created_at": "2024-04-18T14:35:15.479+08:00",
"updated_at": "2024-04-18T14:35:15.479+08:00",
"finished_at": null,
"labels": [
{
"id": 382379,
"name": "enim",
"color": "#428BCA"
},
{
"id": 382378,
"name": "proident",
"color": "#428BCA"
}
],
"stage": "New",
"severity": "Major"
}
Error codes¶
| Error code | Description |
|---|---|
400 |
Invalid parameters or unparsable request |
401 |
Unauthenticated or invalid credentials (missing or invalid access credential) |
404 |
Request path does not exist |
405 |
Unsupported request method |
429 |
Too many requests; rate limit triggered |
500 |
Internal server error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc