POST
/
v1
/
migrations.createKeys
curl --request POST \
  --url https://api.unkey.dev/v1/migrations.createKeys \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '[
  {
    "apiId": "api_123",
    "prefix": "<string>",
    "name": "my key",
    "plaintext": "<string>",
    "hash": {
      "value": "<string>",
      "variant": "sha256_base64"
    },
    "start": "unkey_32kq",
    "ownerId": "team_123",
    "externalId": "user_123",
    "meta": {
      "billingTier": "PRO",
      "trialEnds": "2023-06-16T17:16:37.161Z"
    },
    "roles": [
      "admin",
      "finance"
    ],
    "permissions": [
      "domains.create_record",
      "say_hello"
    ],
    "expires": 1623869797161,
    "remaining": 1000,
    "refill": {
      "interval": "daily",
      "amount": 100
    },
    "ratelimit": {
      "type": "fast",
      "limit": 10,
      "refillRate": 1,
      "refillInterval": 60
    },
    "enabled": false,
    "environment": "<string>"
  }
]'
{
  "keyIds": [
    "key_123",
    "key_456"
  ]
}

Add existing keys to unkey by specifying the key hash and other settings.

This endpoint supports bulk inserts of up to 100 keys at a time. If you have more keys, you can call this endpoint multiple times. If any operation fails (e.g., due to a duplicate key), everything will be rolled back and no keys are created.

Changelog

DateChanges
May 08 2024Introduced endpoint

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json · object[]

The body is of type object[].

Response

200
application/json

The key ids of all created keys

The response is of type object.