Create access token Run in API Explorer

POST /v2/orgs/{name}/access-tokens

Create an access token for an organization.

application/json

Body Required

  • label string

    Label for the access token

  • description string

    Description of the access token

  • resources array[object]

    Resources this token has access to

    Hide resources attributes Show resources attributes object
    • type string

      The type of resource

      Values are TYPE_REPO or TYPE_ORG.

    • path string

      The path of the resource. The format of this will change depending on the type of resource.

    • scopes array[string]

      The scopes this token has access to

  • expires_at string(date-time) | null

    Expiration date for the token

Responses

  • 201 application/json

    Created

    Hide response attributes Show response attributes object
    • id string
    • label string
    • created_by string
    • is_active boolean
    • created_at string(date-time)
    • expires_at string(date-time) | null
    • last_used_at string(date-time) | null
    • token string

      The actual token value that can be used for authentication

    • resources array[object]
      Hide resources attributes Show resources attributes object
      • type string

        The type of resource

        Values are TYPE_REPO or TYPE_ORG.

      • path string

        The path of the resource. The format of this will change depending on the type of resource.

      • scopes array[string]

        The scopes this token has access to

  • 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
  • 403 application/json

    Forbidden

    Hide response attributes Show response attributes object
    • detail string
    • message string
  • 404 application/json

    Not Found

    Hide response attributes Show response attributes object
    • detail string
    • message string
POST /v2/orgs/{name}/access-tokens
curl \
 --request POST 'https://hub.docker.com/v2/orgs/{name}/access-tokens' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"label":"My organization token","description":"Token for CI/CD pipeline","resources":[{"type":"TYPE_REPO","path":"myorg/myrepo","scopes":["repo-pull"]}],"expires_at":"2023-05-20T00:54:18Z"}'
Request examples
{
  "label": "My organization token",
  "description": "Token for CI/CD pipeline",
  "resources": [
    {
      "type": "TYPE_REPO",
      "path": "myorg/myrepo",
      "scopes": [
        "repo-pull"
      ]
    }
  ],
  "expires_at": "2023-05-20T00:54:18Z"
}
Response examples (201)
{
  "id": "a7a5ef25-8889-43a0-8cc7-f2a94268e861",
  "label": "My organization token",
  "created_by": "johndoe",
  "is_active": true,
  "created_at": "2022-05-20T00:54:18Z",
  "expires_at": "2023-05-20T00:54:18Z",
  "last_used_at": "2022-06-15T12:30:45Z",
  "token": "dckr_oat_7awgM4jG5SQvxcvmNzhKj8PQjxo",
  "resources": [
    {
      "type": "TYPE_REPO",
      "path": "myorg/myrepo",
      "scopes": [
        "repo-pull"
      ]
    }
  ]
}
Response examples (400)
{
  "fields": {},
  "text": "string"
}
Response examples (401)
{
  "detail": "string",
  "message": "string"
}
Response examples (403)
{
  "detail": "string",
  "message": "string"
}
Response examples (404)
{
  "detail": "string",
  "message": "string"
}