---
title: "Create API-Key"
description: "API-Keys can be used to access the enterprise API."
stack: "Enterprise Stack (commercial) — version 0.21.0"
stack_version: "0.21.0"
stack_comparison: https://docs.walt.id/community-vs-enterprise.md
canonical_url: https://docs.walt.id/enterprise-stack/administration/access-and-permissions/api-keys/create-api-key
generated: 2026-07-20
---
# Create API-Key

API-Keys can be used to access the enterprise API.

## Create API-Key

<br/>

**Option: CURL**

Endpoint:`/v1/{target}/apikeys-api/api-keys/create` | [API Reference](https://enterprise.sandbox.walt.id/swagger/index.html#/Service%20%2F%20API%20Keys/post_v1__target__apikeys_api_api_keys_create)

**Example Request**

```bash
curl -X 'POST' \
  'https://{orgID}.enterprise-sandbox.waltid.dev/v1/{target}/apikeys-api/api-keys/create' \
  -H 'accept: */*' \
  -H 'Authorization: Bearer {yourToken}' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "expiration": "30d"
}'
```

**Body**

```json
{
  "name": "string",
  "expiration": "30d"
}
```

**Path Parameters**

- `orgID`: - When performing operations within an organization, it is essential to use the organization's Base URL or
  another valid host alias. For example, if your organization is named `test`, your default Base URL will
  be `test.enterprise-sandbox.walt.dev` when using the sandbox environment.
- `target`: _resourceIdentifier_ - The target indicates the organization in which to create the new API Key and the API-Key's
  ID (`{organizationID}.[YourID]`), e.g. `waltid.myApiKey`

**Body Parameters**

- `name`: _String_ - Human readable name for API-Key.
- `expiration`: (optional) _String_ - Expiration time of the API-Key.
  - Set expiration times using the kotlinx.datetime Duration Syntax. Valid units are
    days (d), hours (h), minutes (m), and seconds (s), with finer granularity using milliseconds (ms), microseconds (us),
    and nanoseconds (ns). Examples include `5h`, `1d 12h`, and `1h 0m 30.340s`.

  - Alternatively, you can use a simplified ISO-8601 duration format (PThHmMs.fS), such as P1DT2H3M4.058S. In this format:
    - The largest non-time designator is days (D). Years (Y), weeks (W), and months (M) are not parsed. Instead, use 365d for years, 7d for weeks, and 30d for months.
    - A day is always assumed to be 24 hours (24-hour clock time scale).
    - There is currently no alternative week-based representation like ["P"][number]["W"].

---

**Response**

```json
{
  "_id": "waltid.test1",
  "name": "test",
  "token": "eyJhbGciOiJFZERTQSJ9.eyJzdWIiOiJhYjNhZjc0Zi0wNmNhLTRkY2EtYWJlZi1iNjA3MTJjOTM5YzEiLCJzZXNzaW9uIjoiYXBpLWFiM2FmNzRmLTA2Y2EtNGRjYS1hYmVmLWI2MDcxMmM5MzljMSJ9.FHEmayjhrfZMnOnEecNnOa6ADDwBm1jL_tue64PhxCTk1DZJeIdz-KPvuwWdSlLgw538fqAIoW8ulv6-B91ZAw"
}
```

The returned token can be used as a Bearer token in API requests. 

**Note:**

  If you want to check the expiration time of the API-Key you can use the `/v1/{target}/apikeys-api/api-keys/view` endpoint.
