Authenticate with a Personal Access Token

The Salesforce My Trust Center API authenticates every request with a personal access token (PAT). You create your first PAT in Salesforce My Trust Center. To keep your integration running without manual steps, refresh the PAT from your integration before it expires.

How PATs Work 

  • Scope. A PAT is authorized to access the same tenants that you can access in My Trust Center. Every response is limited to those tenants.
  • Lifetime. A PAT that you create in My Trust Center is valid for 7, 15, or 30 days. A PAT that you get from a refresh is valid for 30 days by default. To get a shorter lifetime, request from 1 through 30 days.
  • One active PAT. You can have only one active PAT. To create a PAT in My Trust Center when you already have one, first revoke your existing PAT.
  • Total lifetime. A PAT and all of its replacements stay valid for no more than 365 days in total. After that, create a PAT in My Trust Center.
  • Format. A PAT is a JSON Web Token (JWT). Its payload contains only the exp claim.
  • Service accounts. To connect your integration by using a service account instead of your own account, use a service account user with the Unified Employee license. A service account user with that license can log in to My Trust Center and create a PAT. The service account user’s PAT can access each tenant where the service account user exists, so create the user in every tenant that you want to monitor. To set up the license and profile, see Give Users Visibility into Salesforce My Trust Center Without a Full License in Salesforce Help.

Create a PAT 

  1. Log in to My Trust Center with your Trailblazer account credentials.
  2. Click the Settings tab.
  3. In the Personal Access Tokens section, click Create Token. If you already have an active PAT, revoke it first.
  4. Enter a label of up to 64 characters that identifies where you use the PAT, such as prod-servicenow.
  5. Select an expiry of 7, 15, or 30 days. The default is 30 days.
  6. Copy the PAT and store it in a secure location, such as a secrets manager. My Trust Center shows the PAT only once.

Treat your PAT like a password. Don’t commit it to source control or include it in logs.

Important

Send the PAT with Each Request 

Send the PAT as a Bearer token in the Authorization header of every request.

Authenticated request
1curl https://api.salesforce.com/platform/mytrust/v1/status \
2  -H "Authorization: Bearer $MYTRUST_PAT"

If the PAT is missing, invalid, revoked, or expired, the API returns 401 with this body.

401 response
1{
2  "error": "unauthorized"
3}

Check When a PAT Expires 

To estimate when a PAT expires, decode the JWT payload locally and read the exp claim. The value is in Unix seconds.

Decode the exp claim
1echo "$MYTRUST_PAT" | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null

The output looks like this.

Decoded payload
1{"exp":1791428400}

Don’t verify the JWT signature, because the signing key isn’t published. The decoded exp value is an estimate. The server’s expiry and revocation status are authoritative. If the command prints a truncated payload, add = padding to the end of the payload segment.

Note

Refresh a PAT 

To replace your current PAT with a new one, send a POST request to /pats/refresh with the current PAT in the Authorization header. The current PAT must be active.

Refresh request
1curl -X POST https://api.salesforce.com/platform/mytrust/v1/pats/refresh \
2  -H "Authorization: Bearer $MYTRUST_PAT" \
3  -H "Content-Type: application/json" \
4  -d '{"expiresInDays": 7}'

The request body is optional. If you omit it, the new PAT is valid for 30 days. To request a shorter lifetime, set expiresInDays to a whole number from 1 through 30.

The response contains the new PAT in secret.

Refresh response
1{
2  "tokenId": "9aa0b1c2-d3e4-4f56-a789-0123456789ab",
3  "secret": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3OTE0Mjg0MDB9.example-signature",
4  "label": "prod-servicenow",
5  "createdAt": "2026-09-08T03:00:00.000Z",
6  "expiresAt": "2026-10-08T03:00:00.000Z"
7}

When the refresh succeeds, the API revokes your current PAT immediately. Store the new secret before you send another request, because the API never returns it again. The old and new PATs don’t overlap, and a refresh isn’t idempotent. If you lose the new PAT, revoke it in My Trust Center, and then create a PAT.

Warning

We recommend that you refresh the PAT on a schedule, well before expiresAt, and write the new secret to your secrets manager in the same step.

Handle Refresh Errors 

A refresh request can fail with an authentication error, a rate-limit error, or a server error. Because a refresh isn’t idempotent, how you recover depends on whether the API replaced your PAT.

401 Unauthorized 

The refresh endpoint returns the same 401 response for every authentication failure.

  • The PAT is missing, malformed, unknown, revoked, or expired.
  • The PAT has reached its 365-day total lifetime.
  • The expiresInDays value is invalid.

For security, the response doesn’t include a message, so the response doesn’t reveal whether your PAT is otherwise valid. To recover, check that expiresInDays is a whole number from 1 through 30, and then retry. If the request still fails, revoke your PAT in My Trust Center, and then create a PAT.

429 Too Many Requests 

If you send too many refresh requests, the API returns 429 with a Retry-After header. The API rejects the request before it replaces your PAT, so your current PAT stays active. Wait the number of seconds in the Retry-After header, and then retry the refresh.

429 response
1{
2  "error": "rateLimitExceeded",
3  "message": "Rate limit exceeded. Retry after the period indicated in the Retry-After header."
4}

500 Internal Server Error or Timeout 

If the refresh returns 500 or times out, you can’t tell from the response whether the API replaced your PAT. Don’t retry the refresh right away. Instead, check whether your current PAT still works.

  1. Send a request that doesn’t change anything, such as listing your tenants, with your current PAT.

    Test the current PAT
    1curl "https://api.salesforce.com/platform/mytrust/v1/tenants?pageSize=1" \
    2  -H "Authorization: Bearer $MYTRUST_PAT"
  2. If the request succeeds, the API didn’t replace your PAT. Wait, and then retry the refresh.

  3. If the request returns 401, the API likely replaced your PAT but didn’t deliver the new one. Revoke your PAT in My Trust Center, and then create a PAT.