---
title: "Create an access token for a service account"
method: POST
path: "/api/v2/service_accounts/{service_account_id}/access_tokens"
tags: ["Service Accounts"]
---

# Create an access token for a service account

`POST /api/v2/service_accounts/{service_account_id}/access_tokens`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/service_accounts/{service_account_id}/access_tokens`
- Auth: API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`

Create an access token for a service account.

## Path parameters

- `service_account_id` string, required

## Request body

- ServiceAccountAccessTokenCreateRequest: Request used to create a service account access token.
  - `data` ServiceAccountAccessTokenCreateData, required: Object used to create a service account access token.
    - `attributes` ServiceAccountAccessTokenCreateAttributes, required: Attributes used to create a service account access token.
      - `expires_at` string, date-time: Expiration date of the access token. Optional for service account tokens.
      - `name` string, required: Name of the access token.
      - `scopes` string[], required: Array of scopes to grant the access token.
    - `type` 'service_access_tokens', required: Service access tokens resource type.

## Response `201`

Created

- ServiceAccessTokenCreateResponse: Response for creating an access token. Includes the token key.
  - `data` FullServiceAccessToken: Datadog access token, including the token key.
    - `attributes` FullServiceAccessTokenAttributes: Attributes of a full access token, including the token key.
      - `created_at` string, date-time: Creation date of the access token.
      - `expires_at` string, date-time, nullable: Expiration date of the access token.
      - `key` string: The access token key. Only returned upon creation.
      - `name` string: Name of the access token.
      - `public_portion` string: The public portion of the access token.
      - `scopes` string[]: Array of scopes granted to the access token.
    - `id` string: ID of the access token.
    - `relationships` ServiceAccessTokenRelationships: Resources related to the access token.
      - `owned_by` RelationshipToServiceAccount: Relationship to service account.
        - `data` RelationshipToServiceAccountData, required: Relationship to service account object.
          - `id` string, required: A unique identifier that represents the service account.
          - `type` 'service_account', required: Service account resource type.
    - `type` 'service_access_tokens': Service access tokens resource type.

## Other responses

- `400`: Bad Request
- `403`: Forbidden
- `404`: Not Found
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/api-v2.md) - [All operations](https://skmtc.dev/datadog/apis/api-v2/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/api-v2/revisions/da68bf029e4c?raw)
