Autenticação
Gerar Token
Produção:
POST
https://oauth2.validapay.com.br/auth/tokenSandbox:
POST
https://oauth2-sandbox.validapay.com.br/auth/tokenEscopos disponíveis
Informe o escopo desejado no parâmetro scope ao solicitar o token. Para múltiplos escopos, separe por espaço.
| Escopo | Descrição |
|---|---|
pix.cob/write | Criar cobranças Pix |
pix.cob/read | Consultar cobranças Pix |
proposals/write | Criar propostas de conta |
proposals/read | Consultar status de propostas |
accounts/write | Criar e gerenciar contas |
accounts/read | Consultar informações de contas |
checkouts/write | Criar checkouts |
checkouts/read | Consultar checkouts |
Autenticação
noauthnoauthstring · header · obrigatório
Nenhuma autenticação via header — credenciais enviadas no body da requisição.
Autentica as credenciais e retorna um token de acesso para uso nas demais rotas da API.
Autenticação M2M (client_credentials)
Gera um access token Bearer para chamadas M2M.
Auth: nenhuma (credenciais no body)
| Campo | Obrig. | Tipo | Descrição |
|---|---|---|---|
grant_type | ✅ | string | client_credentials |
client_id | ✅ | string | ID do cliente M2M |
client_secret | ✅ | string | Secret do cliente M2M |
scope | ✅ | string | Escopos separados por espaço |
Scopes disponíveis: pix.cob/read pix.cob/write wallet/read wallet/write products/read products/write proposals/read proposals/write subscriptions/read subscriptions/write checkouts/read checkouts/write customers/read customers/write subaccounts/read coupons/read coupons/write payment.methods/write
Body
application/json
Content-Type:application/json
{
"grant_type": "client_credentials",
"client_id": "{{client_id}}",
"client_secret": "{{client_secret}}",
"scope": "{{scope}}"
}Schema
| Field | Type | Required | Description |
|---|---|---|---|
grant_type | string | - | - |
client_id | string | - | - |
client_secret | string | - | - |
scope | string | - | - |
Headers
| Name | Type | Value | Required |
|---|---|---|---|
| Content-Type | - | application/json | Optional |
const url = 'https://oauth2.validapay.com.br/auth/token';
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"grant_type": "client_credentials",
"client_id": "{{client_id}}",
"client_secret": "{{client_secret}}",
"scope": "{{scope}}"
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Response Examples
200200
{
"access_token": "eyJ...",
"expires_in": 3600,
"token_type": "Bearer"
}401401
{
"error": "invalid_client",
"error_description": "Client authentication failed"
}