---
title: "Create service-account token"
method: POST
path: "/api/organizations/{name}/service-accounts/{serviceAccountId}/tokens"
tags: ["service-accounts"]
---

# Create service-account token

`POST /api/organizations/{name}/service-accounts/{serviceAccountId}/tokens`

Create a new access token for a service account. Store the token securely - it cannot be retrieved later.

## Path parameters

- `name` string, required
- `serviceAccountId` string, required

## Request body

- object
  - `displayName` string — Display name for the token
  - `permissions` string[] — Org-wide permissions for this token
  - `repoIds` string[] — Repositories to grant `repoPermissions` on. Can be repositories owned by the organization or any public repository. These override the org-wide permissions.
  - `repoPermissions` string[] — Permissions granted on the selected `repoIds`.
  - `endpointPatterns` string[] — Inference endpoint name patterns (wildcards allowed, e.g. `gpt2-*`) restricting the token's org-wide Inference Endpoint permissions to matching endpoints. Empty means all endpoints.
  - `skipNetworkSecurity` boolean — Exempt this token from the org's Network Security enforcement (IP allowlist and content access policy). Enterprise Plus only, and requires the `org.networkSecurity.write` permission.

## Response `201`

Created token

- object
  - `token` string, required — The access token - store this securely, it cannot be retrieved later
  - `tokenInfo` object, required
    - `_id` string, required
    - `displayName` string, required
    - `createdAt` string, required
    - `permissions` string[]
    - `repoIds` string[], required
    - `repoPermissions` string[], required
    - `endpointPatterns` string[], required
    - `skipNetworkSecurity` boolean, required

---

[API](https://skmtc.net/huggingface/apis/hub-api-endpoints.md) · [All operations](https://skmtc.net/huggingface/apis/hub-api-endpoints/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/huggingface/hub-api-endpoints/revisions/01432a33fdd9/schema)
