Skip to main content

Update Git Repository Credential

Update the authorization_token of a Git repository resource. Only the credential can be updated; url, mount_path, and checkout cannot be changed.

Prerequisites

Complete the endpoint and authentication configuration. See API overview and authentication. The session must already have a Git repository mounted.

Endpoint

POST /sessions/{session_id}/resources/{resource_id}

Path parameters

session_id string (required) Session ID in the format sesn_<ULID>. resource_id string (required) Git repository resource ID in the format sesrsc_<ULID>.

Request body

authorization_token string (required) The new access token or password. It cannot be an empty string. You can omit the credential for a public repository when creating the session; this API only replaces an existing token.
The API accepts only authorization_token. If you include url, mount_path, checkout, or other fields, the request returns 400 invalid_parameter.

Request example

curl
curl -X POST "$AGENTSTUDIO_URL/sessions/sesn_xxx/resources/sesrsc_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"authorization_token": "glpat-xxxxxxxxxxxxxxxxxxxx"}'

Response fields

id string Resource ID in the format sesrsc_<ULID>. type string Fixed to git_repository. url string The HTTPS URL of the Git repository. It does not contain credentials. mount_path string The actual mount path of the repository in the session sandbox. checkout object / null The checkout target specified at creation. It contains type and name for a branch, or sha for a commit. It is null when omitted. created_at / updated_at string Resource creation and last update time in ISO 8601. updated_at changes after the credential is updated. request_id string Unique identifier of the request.

Response example

{
  "id": "sesrsc_zzz",
  "type": "git_repository",
  "url": "https://gitlab.com/group/project",
  "mount_path": "/workspace/project",
  "checkout": {"type": "branch", "name": "main"},
  "created_at": "2026-11-28T02:00:55Z",
  "updated_at": "2026-11-28T02:05:57Z",
  "request_id": "xxx"
}

Error codes

Status codeError codeDescription
400invalid_parameterauthorization_token is empty or invalid; the message is Invalid authorization_token
400invalid_parameterA field that cannot be updated is included; the message is Only authorization_token can be updated
404not_foundThe session or resource does not exist
401InvalidApiKeyThe API key is invalid