# Create access token


[API catalog](/reference/api/) · [Docker Hub overview](/reference/api/hub/latest/) · [Product manual](https://docs.docker.com/docker-hub/) · [OpenAPI specification](/reference/api/hub/latest.yaml)

API version: 2-beta



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

Create an access token for an organization.


## Connection and access

[API connection and authentication guidance](/reference/api/hub/latest/#authentication)


Server: `https://hub.docker.com`

Effective security: alternatives are OR; schemes within an alternative are AND. An empty array declares no HTTP authentication requirement.

```json
[
  {
    "bearerAuth": []
  }
]
```
## Example request

Replace placeholders and provide the required credentials or request body.

```console
curl \
  --request POST \
  --header "Authorization: Bearer ${TOKEN}" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "description": "Token for CI/CD pipeline",
  "label": "My organization token",
  "resources": [
    {
      "path": "myorg/myrepo",
      "scopes": [
        "scope-image-pull"
      ],
      "type": "TYPE_REPO"
    }
  ]
}' \
  'https://hub.docker.com/v2/orgs/{name}/access-tokens'
```

## Parameters

## Request and responses

### Request  application/json




Schema:

```json
{
  "$ref": "#/components/schemas/createOrgAccessTokenRequest"
}
```




Schema example:
```json
{
  "description": "Token for CI/CD pipeline",
  "label": "My organization token",
  "resources": [
    {
      "path": "myorg/myrepo",
      "scopes": [
        "scope-image-pull"
      ],
      "type": "TYPE_REPO"
    }
  ]
}
```


### Response 201 application/json

Created


Schema:

```json
{
  "$ref": "#/components/schemas/createOrgAccessTokenResponse"
}
```




Schema example:
```json
{
  "created_at": "2022-05-20T00:54:18Z",
  "expires_at": "2023-05-20T00:54:18Z",
  "id": "a7a5ef25-8889-43a0-8cc7-f2a94268e861",
  "is_active": true,
  "label": "My organization token",
  "last_used_at": "2022-06-15T12:30:45Z",
  "resources": [
    {
      "path": "myorg/myrepo",
      "scopes": [
        "scope-image-pull"
      ],
      "type": "TYPE_REPO"
    }
  ],
  "token": "dckr_oat_7awgM4jG5SQvxcvmNzhKj8PQjxo"
}
```


### Response 400 application/json

Bad Request


Schema:

```json
{
  "$ref": "#/components/schemas/error"
}
```




error:
```json
{
  "errinfo": null,
  "message": "bad request"
}
```


### Response 401 application/json

Unauthorized


Schema:

```json
{
  "$ref": "#/components/schemas/error"
}
```




error:
```json
{
  "errinfo": null,
  "message": "unauthorized"
}
```


### Response 403 application/json

Forbidden


Schema:

```json
{
  "$ref": "#/components/schemas/error"
}
```




error:
```json
{
  "errinfo": null,
  "message": "permission denied"
}
```


### Response 404 application/json

Not Found


Schema:

```json
{
  "$ref": "#/components/schemas/error"
}
```




error:
```json
{
  "errinfo": null,
  "message": "not found"
}
```


## Complete operation contract

```json
{
  "description": "Create an access token for an organization.\n",
  "operationId": "postV2OrgsByNameAccessTokens",
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/createOrgAccessTokenRequest"
        }
      }
    },
    "required": true
  },
  "responses": {
    "201": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/createOrgAccessTokenResponse"
          }
        }
      },
      "description": "Created"
    },
    "400": {
      "$ref": "#/components/responses/BadRequest"
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "403": {
      "$ref": "#/components/responses/Forbidden"
    },
    "404": {
      "$ref": "#/components/responses/NotFound"
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "summary": "Create access token",
  "tags": [
    "org-access-tokens"
  ]
}
```

## Referenced schemas

- `#/components/responses/BadRequest`

- `#/components/responses/Forbidden`

- `#/components/responses/NotFound`

- `#/components/responses/Unauthorized`

- [#/components/schemas/createOrgAccessTokenRequest](/reference/api/hub/latest/schemas/createOrgAccessTokenRequest/)

- [#/components/schemas/createOrgAccessTokenResponse](/reference/api/hub/latest/schemas/createOrgAccessTokenResponse/)




