Skip to main content
A service account is a member of one project with no person behind it. Your production servers call Priors with its key. Its keys keep working when people leave the organization, and it is the only kind of key that can act for one of your own customers with X-SP-End-User.

What a service account reaches

  • Only its own project. A call to an agent in another project returns 404.
  • Only public agents. A service account never reaches a private agent, whatever its role. Every agent it creates is public.
  • Only its own threads. With X-SP-End-User, it reads only the threads that end user created. Without the header, it reads only the threads the service account created itself.

Create a service account and its key

A Project admin or Org admin creates a service account and its first key in one step, in the Priors app:
  1. Open the project’s API keys page and choose Create key.
  2. Name the key and pick how long it lasts: 90 or 365 days, 365 by default. A service-account key always expires.
  3. Tick Mark as service account key, and pick the service account’s role. See the table below.
  4. Choose Generate key, and copy the key. The secret is shown once. Put it straight into your secret manager.
The key looks like spk_<key_id>_<secret>. Note its expiry date when you store it: an expired key returns 401 with no advance warning to your code. The roles mean the same as for a person. See Roles and permissions. A service account cannot make an agent private or change an agent’s visibility. Check the key with GET/v2/me. For a service account, api_key.acts_as.type is service_account.

Rotate a key

  1. Create a new service-account key with the same role, as above. In the Priors app, each new service-account key comes with its own service account.
  2. Deploy the new key to every server.
  3. Revoke the old key on the API keys page. Revocation applies on the next request.
The two keys work side by side until you revoke the old one, so a rotation never stops traffic. Threads that your customers created through X-SP-End-User stay reachable with the new key. Threads that the old service account created without the header stay with the old service account.

Act for one of your customers

Send your own stable id for the customer in X-SP-End-User on every call made for that customer:
The header limits the call to the threads that customer created and gives the customer their own rate-limit window. It does not separate memory: the agent does. Only a service-account key accepts the header. Every other key returns 400. See Authentication.