Create a new identity in the system. This might not be necessary as newly created keys automatically create an identity if required.
Copy
Ask AI
const { result, error } = await unkey.identities.create({ 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);
Copy
Ask AI
{ "result": { "identityId": "id_123" }}
Copy
Ask AI
const { result, error } = await unkey.identities.create({ 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);
The id of this identity in your system.This usually comes from your authentication provider and could be a userId, organisationId or even an email.It does not matter what you use, as long as it uniquely identifies something in your application.externalIds are unique across your workspace and therefore a CONFLICT error is returned when you try to create duplicates.Minimum length: 3Example: "user_123"
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.
const { result, error } = await unkey.identities.create({ 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);
Copy
Ask AI
{ "result": { "identityId": "id_123" }}
Assistant
Responses are generated using AI and may contain mistakes.