unPLUGDevelopers

Member tokens API

Create a member token

POST/v1/member_tokens

Issues a token for one member. Call it from your server only, after you have checked that the guest is signed in to your app. Identify the member by unPLUG id or by your own external_id, whichever you store.

Permissions: Secret key with member_tokens:create.

Request headers#

  • Idempotency-Keystring
    Any string up to 255 characters; use a UUID v4. Kept 24 hours per key (or member) and endpoint. Same key and body replays the first response with Idempotent-Replayed: true.
    Max Length 255

Request body#

  • member_idstring (uuid)
    The member's unPLUG id. Send this or external_id, not both.
  • external_idstring
    Your id for the guest, as set when you created the member.
FieldDescription
tokenstringOpaque. Don't parse it or rely on its length.
expires_atstring15 minutes after issue.
member_idstring (uuid)The member the token acts for.

Keep the token in memory in the app. If you store it, use the platform's secure storage (Keychain on iOS, EncryptedSharedPreferences on Android). On the web, keep it out of localStorage.

Response fields#

Returns 201 with MemberToken

  • tokenstring
    Opaque, starts with mt_.
  • expires_atstring (date-time)
  • member_idstring (uuid)

Error descriptions#

400Bad request
invalid_request

Both or neither of member_id and external_id were sent.

404Not found
member_not_found

No member with that id or external_id. Create the member first with POST /v1/members.

410Gone
member_deleted

The member asked to delete their account. Sign the guest out.

Any endpoint can also return the common errors.