Skip to content

Start the specified space

POST /api/v5/spaces/{owner}/{repo_name}/start

Start the specified space: the server resolves the project by owner / repo_name, then re-pulls the code and deploys and runs the space.

Access token support

  • AtomGit user access tokens

Is anonymous access allowed

This endpoint does not allow anonymous access

Request parameters

Parameter name Location Type Required Description
owner path string Yes The space address the repository belongs to (the address path of the enterprise, organization, or individual)
repo_name path string Yes Repository path (path)
access_token query string Yes User access token

Request Body:

The image, server specification, and runtime duration required to start the space; all three fields are mandatory.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "image_id": {
      "description": "镜像ID",
      "type": "string",
      "minLength": 32,
      "maxLength": 32,
      "example": "swr.cn-south-1.myhuaweicloud.com/atomgit-ai/online-ubuntu22-py311-torch2.8-gradio6.9:v1.0.0"
    },
    "server_id": {
      "description": "服务器规格ID",
      "type": "string",
      "example": "xrtf1hp5jebv32k6zm9o0unlq74g8777"
    },
    "duration_time": {
      "description": "持续时间(秒),到期休眠",
      "type": "number"
    }
  },
  "required": ["image_id", "server_id", "duration_time"]
}

Note: image_id / server_id can be obtained via "Query the list of base images available for the space" and "Query the list of hardware configurations available for the space".

Response parameters

On success, this endpoint returns an empty response body (HTTP 200) and no business data.

Failure responses

400 Parameter error

{
  "error_code_name": "BAD_REQUEST",
  "code": 400,
  "error_message": "镜像不能为空!"
}

401 Unauthenticated

{
  "error_code_name": "UNAUTHORIZED",
  "code": 401,
  "error_message": "Unauthorized"
}

403 No permission

{
  "error_code_name": "FORBIDDEN",
  "code": 403,
  "error_message": "Forbidden"
}

HTTP response status codes

Status code Description
200 Success (OK)
400 Parameter error or project does not exist (Bad Request)
401 Authentication required (Unauthorized)
403 Access forbidden (Forbidden)
500 Internal system error (Internal Server Error)

Request example

Parameter description

Replace <owner> with the space address the repository belongs to (the address path of the enterprise, organization, or individual). If it is a three-segment namespace, for example: gh_mirrors/co/QwenPaw, the owner value is gh_mirrors/co; when calling, you must encode the first / as %2F, so pass owner as: gh_mirrors%2Fco。

Replace <repo_name> with the repository path;

Replace <token> with your AtomGit user access token;

Replace <image_id> with the image ID (32 characters);

Replace <server_id> with the server specification ID;

Replace <duration_time> with the desired runtime duration (in seconds).

cURL

curl -X POST 'https://api.atomgit.com/api/v5/spaces/<owner>/<repo_name>/start?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
    "image_id": "<image_id>",
    "server_id": "<server_id>",
    "duration_time": 3600
  }'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch(
  "https://api.atomgit.com/api/v5/spaces/<owner>/<repo_name>/start?access_token=<YOUR-TOKEN>",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Accept": "application/json",
    },
    body: JSON.stringify({
      image_id: "<image_id>",
      server_id: "<server_id>",
      duration_time: 3600,
    }),
  }
);

if (!response.ok) {
  throw new Error(`请求失败: ${response.status}`);
}

Python

import requests

resp = requests.post(
    "https://api.atomgit.com/api/v5/spaces/<owner>/<repo_name>/start",
    params={"access_token": "<YOUR-TOKEN>"},
    json={
        "image_id": "<image_id>",
        "server_id": "<server_id>",
        "duration_time": 3600,
    },
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

Response Example

Status code: 200

{}

Error Codes

Error code Description
400 Invalid parameters (e.g., missing image_id / server_id / duration_time), or the project does not exist
401 Unauthenticated or invalid credentials (missing/invalid access token)
403 No permission to operate on this space
404 The request path does not exist
405 The request method is 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