const { result, error } = await unkey.identities.update({
  externalId: "user_123",
  ratelimits: [
    {
      name: "tokens",
      limit: 10,
      duration: 1000,
    },
  ],
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "result": {
    "id": "id_1234",
    "externalId": "user_1234",
    "meta": {
      "stripeSubscriptionId": "sub_1234"
    },
    "ratelimits": [
      {
        "name": "tokens",
        "limit": 10,
        "duration": 1000
      }
    ]
  }
}
const { result, error } = await unkey.identities.update({
  externalId: "user_123",
  ratelimits: [
    {
      name: "tokens",
      limit: 10,
      duration: 1000,
    },
  ],
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "result": {
    "id": "id_1234",
    "externalId": "user_1234",
    "meta": {
      "stripeSubscriptionId": "sub_1234"
    },
    "ratelimits": [
      {
        "name": "tokens",
        "limit": 10,
        "duration": 1000
      }
    ]
  }
}

Request

identityId
string
required

The identityId of the identity to update, use either identityId or externalId, if both are provided, identityId takes precedence.

Minimum length: 1

Example: "id_1234"

externalId
string
required

The externalId of the identity to update, use either identityId or externalId, if both are provided, identityId takes precedence.

Minimum length: 1

Example: "user_1234"

meta
object

This is a place for dynamic meta data, anything that feels useful for you should go here

Example:

{
  "billingTier": "PRO",
  "trialEnds": "2023-06-16T17:16:37.161Z"
}
ratelimits
object[]

Attach ratelimits to this identity.

When verifying keys, you can specify which limits you want to use and all keys attached to this identity, will share the limits.

environment
string

This is not yet used but here for future compatibility.

Response

id
string
required

The id of the identity. Used internally, you do not need to store this. Example: "id_123"

externalId
string
required

The id in your system

meta
object
required

This is a place for dynamic meta data, anything that feels useful for you should go here

Example:

{
  "billingTier": "PRO",
  "trialEnds": "2023-06-16T17:16:37.161Z"
}
ratelimits
object[]
required

Attach ratelimits to this identity.

When verifying keys, you can specify which limits you want to use and all keys attached to this identity, will share the limits.