> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.withpersona.com/2020-05-18/api-reference/oauth/create-access-token/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.withpersona.com/_mcp/server. # Create Access Token POST https://api.withpersona.com/api/v1/oauth/token Content-Type: application/x-www-form-urlencoded Exchange a credential for an access token. Supports two grant types: - `authorization_code`: Exchange an authorization code for an access token (cross-org data sharing). - `client_credentials`: Exchange a signed JWT assertion (`private_key_jwt`) for a short-lived access token (machine-to-machine auth, RFC 7523). Reference: https://docs.withpersona.com/api-reference/oauth/create-access-token ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Headers - `Key-Inflection` (enum, optional) — Determines casing for the API response. - Allowed values: `camel`, `kebab`, `snake` - `Idempotency-Key` (string, optional) — Ensures the request is idempotent. - `Persona-Version` (enum, optional) — Server API version. More info on versioning can be found [here](https://docs.withpersona.com/versioning). - Allowed values: `2025-12-08`, `2025-10-27`, `2023-01-05`, `2022-09-01`, `2021-08-18`, `2021-07-05`, `2021-02-21`, `2020-05-18` ### Body (application/x-www-form-urlencoded) This endpoint expects an OAuth_create-access-token_Request. - `OAuth_create-access-token_Request` ## Response ### 201 This endpoint returns an Access Token. - `access-token` (string, required) — Access Token that can be used wherever an API Key would be used. - `expires-in` (integer, required, default: 0) — Number of seconds until the access token expires. - `scope` (string, required) — Space-separated list of granted permissions. Format varies by grant type: for client_credentials, bare permission names (e.g. inquiry.read account.read); for authorization_code, permission:object pairs (e.g. inquiry.read:inq_xxx). Empty string when no permissions are granted. - `token-type` (enum, required) - Allowed values: `bearer`, `Bearer` ## Errors ### 400 Bad Request Error The request was unacceptable, often due to invalid parameters. - `errors` (list of OauthTokenPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 401 Unauthorized Error An invalid API key was provided. - `errors` (list of OauthTokenPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 403 Forbidden Error The given API key doesn’t have permissions to perform the request or a quota has been exceeded. - `errors` (list of OauthTokenPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 404 Not Found Error The requested resource doesn’t exist. - `errors` (list of OauthTokenPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 409 Conflict Error The request conflicts with another request, often due to attempting to create a duplicate resource. - `errors` (list of OauthTokenPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 422 Unprocessable Entity Error The request modifies the resource in an unacceptable way, often due to an invalid action or parameter. - `errors` (list of OauthTokenPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ### 429 Too Many Requests Error Your organization’s rate limit has been exceeded. We recommend an exponential backoff on requests. - `errors` (list of OauthTokenPostResponsesContentApplicationJsonSchemaErrorsItems, optional) ## Types ### authorization_code Exchange an authorization code for an access token. - `code` (string, required) — Authorization Code - `grant-type` (string, required, default: authorization_code) — Must be set to 'authorization_code' ### client_credentials Exchange a signed JWT assertion for a short-lived access token. The JWT must be signed with the private key corresponding to the public key registered on the OAuth client. Note: parameter names follow OAuth RFC 6749/7523 conventions (snake_case) rather than the Persona API default (kebab-case). - `grant_type` (string, required) — Must be set to 'client_credentials' - `client_assertion_type` (string, required) — Must be 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer' - `client_assertion` (string, required) — A signed JWT (RS256 or ES256) with claims: iss, sub (both set to the client_id), aud (the token endpoint URL), jti, iat, and exp (max 5 minutes from now). - `scope` (string, optional) — Optional space-separated list of permissions to request. Must be a subset of the OAuth client's registered permissions. Defaults to all client permissions if omitted. ### OauthTokenPostResponsesContentApplicationJsonSchemaErrorsItems - `title` (string, optional) - `details` (string, optional) ## Examples ### authorization_code grant response **Request** ```json { "code": "string", "grant-type": "authorization_code" } ``` **Response** ```json { "access-token": "persona_access_token_AbCdEfGhIjKlMnOpQrStUvWxYz01234567", "expires-in": 3599, "scope": "inquiry.read:inq_AbCdEfGhIjKlMnOpQrStUvWxYz01234567", "token-type": "bearer" } ``` **SDK Code** ```python authorization_code grant response import requests url = "https://api.withpersona.com/api/v1/oauth/token" payload = "" headers = { "Authorization": "Bearer ", "Content-Type": "application/x-www-form-urlencoded" } response = requests.post(url, data=payload, headers=headers) print(response.json()) ``` ```javascript authorization_code grant response const url = 'https://api.withpersona.com/api/v1/oauth/token'; const options = { method: 'POST', headers: { Authorization: 'Bearer ', 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams('') }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go authorization_code grant response package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.withpersona.com/api/v1/oauth/token" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/x-www-form-urlencoded") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby authorization_code grant response require 'uri' require 'net/http' url = URI("https://api.withpersona.com/api/v1/oauth/token") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/x-www-form-urlencoded' response = http.request(request) puts response.read_body ``` ```java authorization_code grant response import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withpersona.com/api/v1/oauth/token") .header("Authorization", "Bearer ") .header("Content-Type", "application/x-www-form-urlencoded") .asString(); ``` ```php authorization_code grant response request('POST', 'https://api.withpersona.com/api/v1/oauth/token', [ 'form_params' => null, 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/x-www-form-urlencoded', ], ]); echo $response->getBody(); ``` ```csharp authorization_code grant response using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/oauth/token"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); IRestResponse response = client.Execute(request); ``` ```swift authorization_code grant response import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/x-www-form-urlencoded" ] let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/oauth/token")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### client_credentials grant response **Request** ```json { "code": "string", "grant-type": "authorization_code" } ``` **Response** ```json { "access-token": "oat_AbCdEfGhIjKlMnOpQrStUvWxYz01234567", "expires-in": 900, "scope": "inquiry.read account.read", "token-type": "Bearer" } ``` **SDK Code** ```python client_credentials grant response import requests url = "https://api.withpersona.com/api/v1/oauth/token" payload = "" headers = { "Authorization": "Bearer ", "Content-Type": "application/x-www-form-urlencoded" } response = requests.post(url, data=payload, headers=headers) print(response.json()) ``` ```javascript client_credentials grant response const url = 'https://api.withpersona.com/api/v1/oauth/token'; const options = { method: 'POST', headers: { Authorization: 'Bearer ', 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams('') }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go client_credentials grant response package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.withpersona.com/api/v1/oauth/token" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/x-www-form-urlencoded") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby client_credentials grant response require 'uri' require 'net/http' url = URI("https://api.withpersona.com/api/v1/oauth/token") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/x-www-form-urlencoded' response = http.request(request) puts response.read_body ``` ```java client_credentials grant response import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.withpersona.com/api/v1/oauth/token") .header("Authorization", "Bearer ") .header("Content-Type", "application/x-www-form-urlencoded") .asString(); ``` ```php client_credentials grant response request('POST', 'https://api.withpersona.com/api/v1/oauth/token', [ 'form_params' => null, 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/x-www-form-urlencoded', ], ]); echo $response->getBody(); ``` ```csharp client_credentials grant response using RestSharp; var client = new RestClient("https://api.withpersona.com/api/v1/oauth/token"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); IRestResponse response = client.Execute(request); ``` ```swift client_credentials grant response import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/x-www-form-urlencoded" ] let request = NSMutableURLRequest(url: NSURL(string: "https://api.withpersona.com/api/v1/oauth/token")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```