Convert Contacts to Users via the User API

Learn how to convert contacts to users via the User API.

Staffbase Email

In this article, you will learn how to convert contact accounts to user accounts via the User API.

Contacts are user accounts without login access to the Staffbase platform. They can receive emails sent via Staffbase Email, but cannot sign in.

You can convert a contact into a user account with platform access in the following cases:

  • The contact needs additional permissions beyond receiving emails, such as taking on roles in Staffbase Email.

  • You use Staffbase App or Intranet alongside Staffbase Email and want to grant the contact access as an end user.

    To convert a contact to a user, you need to update both the status and role fields.

  • You have already created an API token with administrative access via the Staffbase Studio. Learn more.
  • You have copied your platform’s base URL from the API token page.
  1. Retrieve the contact ID
    If you do not already have the id or externalId of the contact, make a GET request to the endpoint /users/search and filter for accounts with status contact/.

    Terminal window
    export AUTH="Basic {{Token}}"
    # URL Decoded: https://exampleapp.staffbase.com/api/users/search?filter=staffbase.status eq "contact"
    curl -X GET 'https://exampleapp.staffbase.com/api/users/search?filter=staffbase.status%20eq%20%22contact%22' \
    -H 'Authorization: $AUTH' \
    -H 'Accept: application/vnd.staffbase.accessors.users-search.v1+json' \
    -H 'Content-Type: application/vnd.staffbase.accessors.users-search.v1+json' \
    --compressed | json_pp

You have the user ID or the identifier of the contact you want to convert.

  1. Convert the contact
    Make a PATCH request to the endpoint /users/{userID}. In the request body schema, set the following parameters as shown in the example.

    Terminal window
    export USERID="5db0221d0a09a219c4ce9218"
    export AUTH="Basic TOKEN"
    curl "https://exampleapp.staffbase.com/api/users/$USERID" \
    -X PATCH \
    -H "Authorization: $AUTH" \
    -H "Accept: application/vnd.staffbase.accessors.user.v3+json" \
    -H "Content-Type: application/vnd.staffbase.accessors.user-update.v1+json" \
    --data-raw '{
    "status": "pending",
    "role": "reader",
    "sendMail": false
    }' \
    --compressed | json_pp

You can set any role above reader as the status. If no secret property is provided, the platform automatically generates an access code for the user.

You have converted a single contact to a user. To bulk convert multiple contacts, add a function to loop through multiple contacts to perform your requests.