API reference · Authentication

Get Access Token

POSThttps://api.sandbox.cws.digital/oauth/token

Description

Authenticates a platform user and returns the access_token used in all other API calls.

It is the only endpoint that does not require a token. It carries its own Authorization header, with the fixed credential of the integration client, already filled in the Try it panel and in the Postman collection downloaded from the portal.

Request body

Content-Typeapplication/x-www-form-urlencodedRequired
FieldTypeRequiredDescriptionValue
scopestringNo

read, write or trust. If you omit it, the token is issued with all three (read write trust). Any of them authorizes every API route.

grant_typestringYes

Always password.

Allowed values:password
usernamestringYes

E-mail of your user on the CWS platform.

passwordstringYes

Password of your user on the CWS platform.

Business rules

Validity

The access_token is valid for 12 hours (expires_in arrives as 43199, in seconds). When it expires, authenticate again at this same URL.

How to send the token in the other calls

The header is Authorization: Bearer <access_token>, with the Bearer prefix. Without it, the request is rejected with 401.

In the Try it panel, this is already set up: the token returned by this endpoint is saved in this browser tab and filled in on the other endpoints. You do not need to copy anything.

In the Postman collection downloaded from the portal, this request stores the token in the access_token variable, and the other requests inherit the collection header.

Responses

Try it

Sandbox

Language

Credentials

Integration client credential (Basic header of Get Access Token)

Basic YXBpLXdzOnBhc3N3b3JkLW1hc3Rlcg==

This endpoint uses the client credential in the Basic header. The returned token is saved in this tab.

Each token only reaches the partner's own data and that of the branches with an authorized link.

Don't have sandbox credentials yet? See how to request them

Request

cURL
curl --request POST \
  --url 'https://api.sandbox.cws.digital/oauth/token' \
  --header 'Authorization: Basic <client_credential>' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'scope=trust' \
  --data-urlencode 'grant_type=password' \
  --data-urlencode 'username=integracao@lojaexemplo.com.br'

Response

Click Try it to see the real response here, or pick a documented example: