DevelopersHow to connect an assistantKeys
Reference/People/Change

Replace an invitation code

POSThttps://api.getwerk.ai/api/v1/projects/{projectId}/invitations/{invitationId}/replace

Cancels one of the key's person's unused codes and makes a new one in its place.

The new code counts toward the 20 an hour.

Authorization

AuthorizationheaderRequired

Authorization: Bearer <key> Authentication

Path parameters

projectIdstring, uuidRequired

The project's id.

invitationIdstring, uuidRequired

The invitation's id.

Body

clientRequestIdstring, uuidRequired

An id the caller makes for this request. Sent again with the same request, it returns the first answer and changes nothing twice; sent with a different request, it is refused.

Response

201 The new code.

invitationobject

The new invitation.

Show properties of invitationHide properties of invitation
idstring, uuid

The invitation's id.

expiresAtstring, date-time

When the code stops working, 24 hours after it was made.

codestring

The invitation code, shown once: the invited person enters it to join, as a member or as a collaborator when they have no plan of their own.

projectobject

The project the code joins.

Show properties of projectHide properties of project
idstring, uuid

The id Werk's apps use for the key's person's view of the project, not the project's id.

projectIdstring, uuid

The project's id, the one the API's paths take.

namestring

The project's name.

From 1 to 128 characters

Errors

400invalid_queryThe query is not in the form the route takes; the limit is in the unit of the input details.field names (characters for a text, entries for a list, the value for a number).
400invalid_people_requestThe people request is not in the form the route takes; the limit is in the unit of the input details.field names (characters for a text, entries for a list, the value for a number).
401session_revokedThe request carries no session the server holds, or its session has ended.
401session_expiredThe session has expired.
403personal_project_restrictedThe request acts on the signed-in person's own My Werk, which only they see, or on a reminder with no card, which lives there, and My Werk does not take this action.
403not_permittedThe signed-in person's role, or whose the record is, does not allow this request.
404conversation_not_foundThe project the request names, or its chat, is not one the signed-in person is in.
404invitation_not_foundThe invitation the request names is not an open one of this project.
409session_changedThe session changed while the request was in flight.
409project_deletedThe project is being deleted.
409project_archivedThe project is archived, so it does not take this request.
409request_conflictThe request id was already used with another request, or the change it asks could not be made to the record it names.
409request_erasedThe request id belongs to a request whose record was erased.
409code_key_changedThe invitation code or link was made with a key the server no longer holds.
413payload_too_largeThe request body has more bytes than the route takes.
rate_limitedMore requests of this kind were sent than Werk takes within the time it counts them over.
500server_errorThe server could not complete the request, and it is not known whether a write it holds was made.
curl
curl -X POST "https://api.getwerk.ai/api/v1/projects/2f6c9e41-7a3b-4d58-9c1e-0b8d4f2a6e73/invitations/e1c6a4f8-0b3d-4e92-8f7a-5c2d9b1e6a30/replace" \
  -H "Authorization: Bearer wk_key_..." \
  -H "Content-Type: application/json" \
  -d '{
    "clientRequestId": "f1e2d3c4-b5a6-4978-8a9b-0c1d2e3f4d05"
  }'
TypeScript
const res = await fetch("https://api.getwerk.ai/api/v1/projects/2f6c9e41-7a3b-4d58-9c1e-0b8d4f2a6e73/invitations/e1c6a4f8-0b3d-4e92-8f7a-5c2d9b1e6a30/replace", {
  method: "POST",
  headers: {
    Authorization: "Bearer wk_key_...",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "clientRequestId": "f1e2d3c4-b5a6-4978-8a9b-0c1d2e3f4d05"
  }),
});
const answer = await res.json();
201JSON
{
  "invitation": {
    "id": "e1c6a4f8-0b3d-4e92-8f7a-5c2d9b1e6a30",
    "expiresAt": "2026-11-22T14:05:00.000Z"
  },
  "code": "R2D-9VN",
  "project": {
    "id": "9e3b1c75-4f2a-4d86-b0c9-5a7e2d1f8c36",
    "name": "Harbor Street kitchen"
  }
}