> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a service account key

> Create a key for an existing service account.

API referenceApplies to: Workspaces with access management

`POST /api/v1/service-accounts/{name}/keys`

Create a key for an existing service account.

## Access

An administrator needs `serviceaccounts:update` permission in this workspace.

[Choose the right workspace credential](https://docs.e6data.com/api-reference/authentication.md). Ask your workspace administrator whether this API is available in your workspace.

For this example, set `ACCESS_TOKEN` to a user's [personal access token (PAT)](https://docs.e6data.com/platform/tokens/create-rotate-revoke.md#personal-access-tokens) with the permission above. A machine-client OAuth token also needs active permission enforcement and a role binding that grants this action to the client. Ask your administrator to confirm both.

## Request

Path: `{name}` is the service account name. JSON body requires a key `name` (1-128 characters). Optional `expiresAt` is an RFC3339 timestamp. Save `apiKey` when it is returned because the full secret is shown once.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --proto '=https' --silent --show-error --fail-with-body \
  --request POST \
  --header @- \
  --header 'Content-Type: application/json' \
  --data '{"name":"reporting-job"}' \
  "$WORKSPACE_URL/api/v1/service-accounts/ci-reporter/keys" <<< "Authorization: Bearer $ACCESS_TOKEN"
```

## Response

HTTP `201`. Example response with sample values:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "keyId": "6b9a5a53-38aa-4903-a2be-317d4c122589",
  "name": "reporting-job",
  "apiKey": "<shown-once-key>",
  "createdAt": "2026-11-20T10:00:00Z",
  "message": "API key created. Save it now - it won't be shown again."
}
```

## If the request fails

For `401`, check the workspace URL and token. For `403`, ask your administrator to check your access. For `400`, check the name and expiry. For `404`, check the service account name.

[Return to the API endpoint directory](https://docs.e6data.com/api-reference/endpoints.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.