This page describes how to authenticate against the Pentacode API and get access to the full REST API for one company
Step 1: Get a client id and secret
Before you can start using the Pentacode API, you need to get a client id and client secret. These will be used to retrieve auth tokens which in turn are used to authenticate with the API endpoints that require authentication.
To get a client id and secret please contact us a [email protected].
Important: The client secret is called secret for a reason! Don't expose the client secret in an insecure environment or commit it to source control!
Step 2: Retrieve an auth token
Using your client id and secret, you can now make a call to the /auth/token endpoint to retrieve an auth token. Auth tokens are restricted to a single company, so you'll also have to provide the company id. Lastly, a list of scopes can be specified to restrict the permissions granted to the token bearer. If not provided, the full list of available scopes is used.
In order to retrieve an auth token for a given company, you'll need to be granted access first. There is currently no automatic process to request access to a given company id, so for this you'll also need to reach out to us via [email protected].
POST /rest/v1/auth/token HTTP/1.1
Accept: application/json
Content-Type: application/json
Host: api.pentacode.app
{
"clientId": "[your client id]",
"clientSecret": "[your client secret]",
"companyId": 123,
"scopes": []
}
{
"id": "fd336784-21fe-49d2-9dbf-f956123e6011",
"token": "[your token]",
"companyId": 123,
"clientId": "fe544271-3768-4d38-a59e-345f704bafde",
"expires": null,
"scopes": []
}
Step 3: Use the auth token in a request
You can now use the token value from the response to authenticate subsequent requests. To do so, simply include the token in the Authorization header with the Bearer prefix:
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer [token]" \
https://api.pentacode.app/rest/v1/company
Step 4: Refresh the token
Each auth token is valid for 24 hours only.
Should you receive the following status code, rerun the authentication flow with your client id and secret (step 2) to retrieve a new token for your request.
Status Code: 401 (Unauthorized)
{
"error": "Token expired."
}
