Create API-Key

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

Create API-Key


CURL

Endpoint:/v1/{target}/apikeys-api/api-keys/create | API Reference

Example Request

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

{
  "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

{
  "_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.

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