Skip to main content

Invite Links API

This page documents the 4 gateway endpoints tagged Invite Links in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.

MethodPathSummary
POST/invitation/newCreate an invitation link for a user
GET/invitation/infoGet an invitation link
POST/invitation/updateMark an invitation link accepted
POST/invitation/deleteRevoke an invitation link

Endpoints​

POST /invitation/new​

Create an invitation link for a user

Create a one time link that lets an existing user set up their Admin UI login, for onboarding a colleague without sharing a password. Send the user_id and give the user the link built from the returned id. The link works for seven days. Proxy admins can invite anyone, and organization or team admins only users in their own organization or team. The new invitation is written to the audit log.

Request body (application/json, schema InvitationNew):

FieldTypeRequiredDescription
user_idstringYesThe existing user the invitation link is for.

Example request:

curl -X POST "http://localhost:4000/invitation/new" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user-123"
}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json InvitationModel
400You can only create invitations for users in your organization or team.application/json ProxyError
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
idstringYesThe invitation id, which is the token in the invitation link.
user_idstringYesThe user the invitation is for.
is_acceptedbooleanYesTrue once the user opened the link and signed in.
accepted_atstring or nullYesWhen the user accepted, empty until then.
expires_atstringYesWhen the link stops working, seven days after it was created.
created_atstringYesWhen the invitation was created.
created_bystringYesThe user who created the invitation.
updated_atstringYesWhen the invitation last changed.
updated_bystringYesThe user who last changed the invitation.

GET /invitation/info​

Get an invitation link

Read one invitation by its id, to see whether it was accepted and when it expires. Proxy admins and admin viewers may call it, and nothing changes.

Parameters:

NameInTypeRequiredDescription
invitation_idquerystringYes

Example request:

curl -X GET "http://localhost:4000/invitation/info?invitation_id=invitation_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json InvitationModel
400No database is connected, the key is not an admin, or the invitation does not existapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
idstringYesThe invitation id, which is the token in the invitation link.
user_idstringYesThe user the invitation is for.
is_acceptedbooleanYesTrue once the user opened the link and signed in.
accepted_atstring or nullYesWhen the user accepted, empty until then.
expires_atstringYesWhen the link stops working, seven days after it was created.
created_atstringYesWhen the invitation was created.
created_bystringYesThe user who created the invitation.
updated_atstringYesWhen the invitation last changed.
updated_bystringYesThe user who last changed the invitation.

POST /invitation/update​

Mark an invitation link accepted

Set by hand whether an invitation was accepted. Signing in through the invitation link already marks it accepted, so this is for invitations accepted some other way. Only the invited user or a proxy admin may call it. The change is written to the audit log.

Request body (application/json, schema InvitationUpdate):

FieldTypeRequiredDescription
invitation_idstringYesInvitation Id
is_acceptedbooleanYesIs Accepted

Example request:

curl -X POST "http://localhost:4000/invitation/update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"invitation_id": "inv-5c2d",
"is_accepted": true
}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json InvitationModel
400No database is connected or the invitation does not existapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller is neither the invited user nor a proxy adminapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The key carries no user id to record as the one who acceptedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
idstringYesThe invitation id, which is the token in the invitation link.
user_idstringYesThe user the invitation is for.
is_acceptedbooleanYesTrue once the user opened the link and signed in.
accepted_atstring or nullYesWhen the user accepted, empty until then.
expires_atstringYesWhen the link stops working, seven days after it was created.
created_atstringYesWhen the invitation was created.
created_bystringYesThe user who created the invitation.
updated_atstringYesWhen the invitation last changed.
updated_bystringYesThe user who last changed the invitation.

POST /invitation/delete​

Revoke an invitation link

Delete an invitation so its link stops working, for example when it was sent to the wrong person. Proxy admins can revoke any invitation, and organization admins only the ones they created. The deletion is written to the audit log.

Request body (application/json, schema InvitationDelete):

FieldTypeRequiredDescription
invitation_idstringYesInvitation Id

Example request:

curl -X POST "http://localhost:4000/invitation/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"invitation_id": "inv-5c2d"
}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json InvitationModel
400No database is connected, the key is not an admin, or the invitation does not existapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403An organization admin tried to revoke an invitation someone else createdapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
idstringYesThe invitation id, which is the token in the invitation link.
user_idstringYesThe user the invitation is for.
is_acceptedbooleanYesTrue once the user opened the link and signed in.
accepted_atstring or nullYesWhen the user accepted, empty until then.
expires_atstringYesWhen the link stops working, seven days after it was created.
created_atstringYesWhen the invitation was created.
created_bystringYesThe user who created the invitation.
updated_atstringYesWhen the invitation last changed.
updated_bystringYesThe user who last changed the invitation.