---
title: "Create API key"
method: POST
path: "/api/v2/service-account/{id}/api-key"
tags: ["service-account"]
---

# Create API key

`POST /api/v2/service-account/{id}/api-key`

## Request

- Base URL: `https://central.zerotier.com`
- URL: `https://central.zerotier.com/api/v2/service-account/{id}/api-key`
- Auth: HTTP bearer

Create a new API key for a service account. The secret key value is returned **only once** in this response — store it securely, as it cannot be retrieved again.

## Path parameters

- `id` string, required

## Request body

- CreateApiKeyRequest
  - `description` string
  - `expires` string, date-time, required

## Response `200`

Created API key (secret is only returned in this response)

- NewApiKeyResponse
  - `id` string, required
  - `serviceAccountId` string, required
  - `description` string, required
  - `expires` string, date-time, required: Expiration time of the API key
  - `key` string, required: The API key value
  - `creationTime` string, date-time, required: Time the API key was created
  - `lastModified` string, date-time, required: Time the API key was last modified

## Other responses

- `400`: Invalid data provided
- `401`: Missing or invalid authentication token
- `403`: Insufficient permissions
- `413`: Request body exceeds the 1 MB size limit
- `500`: Internal server error

---

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