Skip to content
undertext developers
Skip to Content
undertext developers
REST API

Users

Create users under your own ids, look them up, merge and delete them, list their documents, and set Verified Presence for them.

A user is one of your people. Undertext gives each user its own id, usr_…, and keeps your id for them beside it as external_id. Every other endpoint, event and seal names users by Undertext id. Undertext has no accounts and no sign-in: you create a user with a name, and from then on Undertext credits what that user writes in the editor to that name. See Users for how the two ids, names, pictures and deletion work.

The user object

AttributeTypeDescription
idstringUndertext's id for this user, usr_ and 8 characters. It never changes.
external_idstringYour id for this user, 1 to 128 characters, unique on your platform.
namestringThe name Undertext shows on their writing, comments, cursors and seals. Up to 48 characters.
avatar_urlstring or nullUndertext's copy of their picture, or null for initials.
detailstring or nullA second line shown under their name where people pick someone to mention, such as an email address or a team.
created_attimestampWhen you first created the user.
{
  "id": "usr_5Kq2Lm8R",
  "external_id": "u_42",
  "name": "Ada Lovelace",
  "avatar_url": "https://api.undertext.sh/v1/avatars/av_9Rk3Tq",
  "detail": "ada@acme.com",
  "created_at": "2026-10-12T09:14:03Z"
}

Create or update a user

PUT /v1/users/external/{external_id}

Creates a user for your id if there isn't one, and replaces their name, picture and detail if there is. Call it when someone signs up, and again whenever their profile changes in your product. Keep the id it returns beside your user.

A new name shows everywhere at once, in every document and open editor, because documents name people by Undertext id. Seals already made keep the name they were sealed with.

ParameterTypeDescription
external_idstring, path, requiredYour id for this user. URL-encode it.
namestring, requiredUp to 48 characters, without control or invisible characters.
avatar_urlstringAn https URL of a PNG, JPEG or WebP picture of at most 1 MB, on a public address. Undertext fetches it once and keeps its own copy; send the same URL again and it isn't fetched again. null removes the picture. Leave it out to keep the current one.
detailstringUp to 128 characters. null removes it. Leave it out to keep the current one.
curl https://api.undertext.sh/v1/users/external/u_42 \
  -X PUT \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ada Lovelace",
    "avatar_url": "https://acme.com/avatars/42.png",
    "detail": "ada@acme.com"
  }'

Returns the user: 201 when it was created, 200 when it was updated.

{
  "id": "usr_5Kq2Lm8R",
  "external_id": "u_42",
  "name": "Ada Lovelace",
  "avatar_url": "https://api.undertext.sh/v1/avatars/av_9Rk3Tq",
  "detail": "ada@acme.com",
  "created_at": "2026-10-12T09:14:03Z"
}
ErrorWhen
400 invalid_parameter on nameThe name is empty, longer than 48 characters, or has control or invisible characters.
400 invalid_parameter on external_idEmpty, or longer than 128 characters.
400 avatar_unreadableUndertext couldn't fetch the picture, or it isn't a PNG, JPEG or WebP of at most 1 MB.

Retrieve a user

GET /v1/users/{id}

ParameterTypeDescription
idstring, path, requiredThe user's Undertext id.
curl https://api.undertext.sh/v1/users/usr_5Kq2Lm8R \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY"

Returns the user, or 404 user_not_found.

Retrieve a user by your id

GET /v1/users/external/{external_id}

For when you have only your own id, for example before you've stored the Undertext id.

ParameterTypeDescription
external_idstring, path, requiredYour id for this user. URL-encode it.
curl https://api.undertext.sh/v1/users/external/u_42 \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY"

Returns the user, or 404 user_not_found.

Update a user

PATCH /v1/users/{id}

Changes any of a user's fields by Undertext id, including external_id: use it when your ids change, in a migration or when someone switches login method. Documents, seals and agents follow the Undertext id, so nothing else moves.

ParameterTypeDescription
idstring, path, requiredThe user's Undertext id.
external_idstringA new id of yours for this user. It must not belong to another user.
namestringAs in Create or update a user.
avatar_urlstring or nullAs above.
detailstring or nullAs above.
curl https://api.undertext.sh/v1/users/usr_5Kq2Lm8R \
  -X PATCH \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"external_id": "2f6c1e0a-7b1d-4c55-9e0f-3a8d2b6c9e41"}'

Returns the user.

ErrorWhen
409 external_id_takenAnother user already has that external_id. Merge the two first if they're the same person.
404 user_not_foundNo user with that id.

Delete a user

DELETE /v1/users/{id}

Removes the user from Undertext. Call it when someone deletes their account in your product. Their external_id is free again afterwards; using it again creates a new person.

  • Documents they wrote in keep the last name they had, without their picture, so the record of who wrote what stays readable.
  • Documents they owned pass to their other members: those with the highest role become owners. A document with no other member passes to someone else who wrote in it, if anyone did, and is otherwise deleted, with its seals. One in the trash with no owner left is deleted.
  • Their agents are revoked, and their open editors close.
  • Their security keys and check-in history are deleted.
ParameterTypeDescription
idstring, path, requiredThe user's Undertext id.
curl https://api.undertext.sh/v1/users/usr_5Kq2Lm8R \
  -X DELETE \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY"
{
  "id": "usr_5Kq2Lm8R",
  "deleted": true
}

A document that still has other members isn't deleted when its owner is. Make someone an owner first with PUT /v1/documents/{document_id}/members/{user_id} if you want a particular person to own it; otherwise every member with the highest role becomes an owner.

Merge users

POST /v1/users/{id}/merge

Moves everything from one user to another, then deletes the first. Use it when someone who started without an account signs up or signs in, so their work comes with them. See Anonymous users.

What moves:

  • their documents and memberships (where both users were members, the higher role is kept), and documents in their own trash
  • the credit for everything they and their agents wrote, typed, shaped or accepted, in every document
  • their security keys (after into's own), their check-ins, their presence signals, and the documents they turned Verified Presence on in
  • their agents. An agent for a client into already has an agent for joins that one, keeping the higher role in each document and its tokens, so it needn't be approved again.

Open editors of the user merged from lose their sessions: start new ones as into.

ParameterTypeDescription
idstring, path, requiredThe user to merge from. It's deleted afterwards.
intostring, requiredThe Undertext id of the user to merge into. It must exist.
curl https://api.undertext.sh/v1/users/usr_2Hd7Np4Q/merge \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"into": "usr_5Kq2Lm8R"}'

Returns the user merged into.

{
  "id": "usr_5Kq2Lm8R",
  "external_id": "u_42",
  "name": "Ada Lovelace",
  "avatar_url": null,
  "detail": "ada@acme.com",
  "created_at": "2026-10-30T18:20:00Z"
}
ErrorWhen
400 invalid_parameter on intointo is the same user.
404 user_not_foundEither user doesn't exist.

List a user's documents

GET /v1/users/{id}/documents

The documents a user is a member of, most recently edited or shared with them first, leaving out those in the trash. Use it to build your document list; keep your own folders and pins beside it, keyed by document id.

ParameterTypeDescription
idstring, path, requiredThe user's Undertext id.
idsstringComma-separated document ids: only those of them the user may open now, as a member or by link access. For titles and access of documents you keep elsewhere, such as in a notification list.
trashedbooleantrue lists what's in their trash instead, most recently trashed first: documents an owner trashed for everyone, where they're an owner, and documents they put in their own. Default false.
limitinteger1 to 100. Default 50.
afterstringThe next cursor from the previous page.
curl "https://api.undertext.sh/v1/users/usr_5Kq2Lm8R/documents?limit=2" \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY"

Each item is a document with two more fields: role, this user's role in it (the higher of their member role and the link's), and added_at, when they became a member, or null for one they reach by link. With trashed=true, each has instead everyone, true when it's in the trash for everyone and false when only in theirs, and in_trash_since.

{
  "data": [
    {
      "id": "doc_8Hq2Lm4R",
      "name": "On the Analytical Engine",
      "title": "On the Analytical Engine",
      "owners": ["usr_5Kq2Lm8R"],
      "link_access": "restricted",
      "created_at": "2026-10-13T21:12:40Z",
      "edited_at": "2026-10-30T16:30:52Z",
      "trashed_at": null,
      "role": "owner",
      "added_at": "2026-10-13T21:12:40Z"
    },
    {
      "id": "doc_3Wp7Zc1V",
      "name": null,
      "title": "Notes for Thursday",
      "owners": ["usr_9Tb3Wc1X"],
      "link_access": "suggest",
      "created_at": "2026-10-11T15:02:11Z",
      "edited_at": "2026-10-12T08:47:30Z",
      "trashed_at": null,
      "role": "suggester",
      "added_at": "2026-10-11T15:40:02Z"
    }
  ],
  "next": "c_2Fh8Kq"
}

Empty a user's trash

DELETE /v1/users/{id}/trash

DELETE /v1/users/{id}/trash/{document_id}

Deletes for good everything in a user's trash, or one document there. A document in the trash for everyone, where they're an owner, is deleted for everyone; one in their own trash they leave, as a member, and it stays for the others.

ParameterTypeDescription
idstring, path, requiredThe user's Undertext id.
document_idstring, pathOne document in their trash.
curl https://api.undertext.sh/v1/users/usr_5Kq2Lm8R/trash \
  -X DELETE \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY"
{ "user": "usr_5Kq2Lm8R", "deleted": 3 }

For one document, { "user": …, "document": …, "deleted": true }, or 404 document_not_found when it isn't in their trash.

End a user's sessions

DELETE /v1/users/{id}/sessions

Ends a user's editor and presence sessions, all of them or one group's, as when they sign out. Described with the other session endpoints: see End a user's sessions.

List a user's agents

GET /v1/users/{id}/agents

The agents a user has connected, newest first. This endpoint is described with the other agent endpoints: see List a user's agents.

Retrieve a user's security keys

GET /v1/users/{id}/checkins

How many security keys a user has. Turning Verified Presence on needs one, and people add them only in presence settings, on Undertext's own domain. See Presence and check-ins.

ParameterTypeDescription
idstring, path, requiredThe user's Undertext id.
curl https://api.undertext.sh/v1/users/usr_5Kq2Lm8R/checkins \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY"
{
  "user": "usr_5Kq2Lm8R",
  "security_keys": 2
}
AttributeTypeDescription
userstringThe user's Undertext id.
security_keysintegerHow many security keys they've added.

Retrieve Verified Presence in a document

GET /v1/documents/{document_id}/checkins/{user_id}

Whether Verified Presence is on for a user in a document: whether they're asked to check in while they write there. It's their own switch, so each person in a document has one, unless your platform requires it.

ParameterTypeDescription
document_idstring, path, requiredThe document's id.
user_idstring, path, requiredThe user's Undertext id.
curl https://api.undertext.sh/v1/documents/doc_8Hq2Lm4R/checkins/usr_5Kq2Lm8R \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY"
{
  "document": "doc_8Hq2Lm4R",
  "user": "usr_5Kq2Lm8R",
  "enabled": true,
  "required": false
}
AttributeTypeDescription
documentstringThe document's id.
userstringThe user's Undertext id.
enabledbooleanWhether they're asked to check in while they write in the document.
requiredbooleanWhether your platform requires Verified Presence, so it's on and can't be turned off.

Turn Verified Presence on or off in a document

PUT /v1/documents/{document_id}/checkins/{user_id}

Turns Verified Presence on or off for a user in one document. On, they're asked to check in while they write there, as often as your platform has check-ins come; in documents where it's off, they aren't asked. People can also turn it on themselves in the editor, and your page can with editor.setVerifiedPresence().

ParameterTypeDescription
document_idstring, path, requiredThe document's id.
user_idstring, path, requiredThe user's Undertext id.
enabledboolean, requiredtrue to turn it on, false to turn it off.
curl https://api.undertext.sh/v1/documents/doc_8Hq2Lm4R/checkins/usr_5Kq2Lm8R \
  -X PUT \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"enabled": true}'

Returns the same object as retrieving it.

ErrorWhen
400 invalid_parameter on enabledNot true or false.
409 no_security_keysTurning it on for a user with no security keys yet. Open presence settings for them to add one.
409 checkins_requiredTurning it off where your platform requires it.

On this page