Create personal access token Run in API Explorer

POST /v2/access-tokens

Creates and returns a personal access token.

application/json

Body Required

  • token_label string Required

    Friendly name for you to identify the token.

    Minimum length is 1, maximum length is 100.

  • scopes array[string] Required

    Valid scopes: "repo:admin", "repo:write", "repo:read", "repo:public_read"

  • expires_at string(date-time)

    Optional expiration date for the token. If omitted, the token will remain valid indefinitely.

Responses

  • 201 application/json

    Created

    Hide response attributes Show response attributes object
    • uuid string
    • client_id string
    • creator_ip string
    • creator_ua string
    • created_at string
    • last_used string | null
    • generated_by string
    • is_active boolean
    • token string
    • token_label string
    • scopes array[string]
  • 400 application/json

    Bad Request

    Hide response attributes Show response attributes object
    • fields object
    • text string
  • 401 application/json

    Unauthorized

    Hide response attributes Show response attributes object
    • detail string
    • message string
POST /v2/access-tokens
curl \
 --request POST 'https://hub.docker.com/v2/access-tokens' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"token_label":"My read only token","scopes":["repo:read"],"expires_at":"2021-10-28T18:30:19.520861Z"}'
Request examples
{
  "token_label": "My read only token",
  "scopes": [
    "repo:read"
  ],
  "expires_at": "2021-10-28T18:30:19.520861Z"
}
Response examples (201)
{
  "uuid": "b30bbf97-506c-4ecd-aabc-842f3cb484fb",
  "client_id": "HUB",
  "creator_ip": "127.0.0.1",
  "creator_ua": "some user agent",
  "created_at": "2021-07-20T12:00:00.000000Z",
  "last_used": "string",
  "generated_by": "manual",
  "is_active": true,
  "token": "a7a5ef25-8889-43a0-8cc7-f2a94268e861",
  "token_label": "My read only token",
  "scopes": [
    "repo:read"
  ]
}
Response examples (400)
{
  "fields": {},
  "text": "string"
}
Response examples (401)
{
  "detail": "string",
  "message": "string"
}