MENU navbar-image

Introdução

Documentação da API Middleware para Pix da SSG
Documentação em desenvolvimento. Não siga fielmente os exemplos.

Autenticando Requests

Para autenticar requests, inclua o cabeçalho Authorization com o valor "Bearer {ACCESS_TOKEN}".

Todos os endpoints protegidos com autenticação são marcados com um selo requer autenticação na documentação abaixo.

Obtenha o token de acesso através do endpoint POST /oauth/token

Requests

Pix Status

requires authentication

Endpoint para obter o status de um pix

Exemplo de request:
curl --request POST \
    "http://smartsafe.dyndns.tv:81/api/qrcode/status" \
    --header "Authorization: Bearer {ACCESS_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"qrcode_id\": \"aspernatur\"
}"
const url = new URL(
    "http://smartsafe.dyndns.tv:81/api/qrcode/status"
);

const headers = {
    "Authorization": "Bearer {ACCESS_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "qrcode_id": "aspernatur"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'http://smartsafe.dyndns.tv:81/api/qrcode/status';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {ACCESS_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'qrcode_id' => 'aspernatur',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://smartsafe.dyndns.tv:81/api/qrcode/status'
payload = {
    "qrcode_id": "aspernatur"
}
headers = {
  'Authorization': 'Bearer {ACCESS_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Exemplo de response (200, Status retornado):


{
    "data": {
        "qrcode_id": "61e61d4a-811...",
        "status": "PENDENTE"
    }
}
 

Exemplo de response (404, Não encontrado):


{
    "codigo_erro": 543235,
    "mensagem": "ID não encontrado"
}
 

Request   

POST api/qrcode/status

Headers

Authorization      

Example: Bearer {ACCESS_TOKEN}

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

qrcode_id   string   

Example: aspernatur

Gerar QR Code

requires authentication

Endpoint para gerar um QR Code

Exemplo de request:
curl --request POST \
    "http://smartsafe.dyndns.tv:81/api/generate-qrcode" \
    --header "Authorization: Bearer {ACCESS_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"valor\": \"107080452L31\",
    \"chave\": \"aspernatur\",
    \"data_expiracao\": \"2024-06-21T16:15:59\",
    \"nome_pagador\": \"cmlz\",
    \"email_pagador\": \"wjsq\",
    \"documento_pagador\": \"u\",
    \"cep_pagador\": \"srqhlbbz\",
    \"endereco_pagador\": \"qczp\",
    \"cidade_pagador\": \"hgoz\",
    \"uf_pagador\": \"wf\",
    \"account_id\": \"06919b2b-4274-357a-84b0-4cf4de1405fb\"
}"
const url = new URL(
    "http://smartsafe.dyndns.tv:81/api/generate-qrcode"
);

const headers = {
    "Authorization": "Bearer {ACCESS_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "valor": "107080452L31",
    "chave": "aspernatur",
    "data_expiracao": "2024-06-21T16:15:59",
    "nome_pagador": "cmlz",
    "email_pagador": "wjsq",
    "documento_pagador": "u",
    "cep_pagador": "srqhlbbz",
    "endereco_pagador": "qczp",
    "cidade_pagador": "hgoz",
    "uf_pagador": "wf",
    "account_id": "06919b2b-4274-357a-84b0-4cf4de1405fb"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'http://smartsafe.dyndns.tv:81/api/generate-qrcode';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {ACCESS_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'valor' => '107080452L31',
            'chave' => 'aspernatur',
            'data_expiracao' => '2024-06-21T16:15:59',
            'nome_pagador' => 'cmlz',
            'email_pagador' => 'wjsq',
            'documento_pagador' => 'u',
            'cep_pagador' => 'srqhlbbz',
            'endereco_pagador' => 'qczp',
            'cidade_pagador' => 'hgoz',
            'uf_pagador' => 'wf',
            'account_id' => '06919b2b-4274-357a-84b0-4cf4de1405fb',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://smartsafe.dyndns.tv:81/api/generate-qrcode'
payload = {
    "valor": "107080452L31",
    "chave": "aspernatur",
    "data_expiracao": "2024-06-21T16:15:59",
    "nome_pagador": "cmlz",
    "email_pagador": "wjsq",
    "documento_pagador": "u",
    "cep_pagador": "srqhlbbz",
    "endereco_pagador": "qczp",
    "cidade_pagador": "hgoz",
    "uf_pagador": "wf",
    "account_id": "06919b2b-4274-357a-84b0-4cf4de1405fb"
}
headers = {
  'Authorization': 'Bearer {ACCESS_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Exemplo de response (201, QR Code gerado):


{
    "data": {
        "id": "61e61d4a-811...",
        "qrcode": "00020126570014br.gov.bcb.pix011181..."
    }
}
 

Request   

POST api/generate-qrcode

Headers

Authorization      

Example: Bearer {ACCESS_TOKEN}

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

valor   string   

Must match the regex /^\d{1,12}.\d{2}/. Example: 107080452L31

chave   string   

Example: aspernatur

data_expiracao   string   

Must be a valid date. Example: 2024-06-21T16:15:59

nome_pagador   string   

Must not be greater than 255 characters. Example: cmlz

email_pagador   string   

Must be a valid email address. Must not be greater than 255 characters. Example: wjsq

documento_pagador   string   

Must match the regex /^\d{11,14}$/. Must be at least 11 characters. Must not be greater than 14 characters. Example: u

cep_pagador   string   

Must match the regex /^\d{8}$/. Must be 8 characters. Example: srqhlbbz

endereco_pagador   string   

Must not be greater than 255 characters. Example: qczp

cidade_pagador   string   

Must not be greater than 255 characters. Example: hgoz

uf_pagador   string   

Must be 2 characters. Example: wf

account_id   string   

Must be a valid UUID. Example: 06919b2b-4274-357a-84b0-4cf4de1405fb

Atualizar o status de um pix

requires authentication

Este endpoint tem sua utilização exclusiva de APIs externas

Exemplo de request:
curl --request PATCH \
    "http://smartsafe.dyndns.tv:81/api/pix/aspernatur" \
    --header "Authorization: Bearer {ACCESS_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"status\": \"PAGO\"
}"
const url = new URL(
    "http://smartsafe.dyndns.tv:81/api/pix/aspernatur"
);

const headers = {
    "Authorization": "Bearer {ACCESS_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "PAGO"
};

fetch(url, {
    method: "PATCH",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'http://smartsafe.dyndns.tv:81/api/pix/aspernatur';
$response = $client->patch(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {ACCESS_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'status' => 'PAGO',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://smartsafe.dyndns.tv:81/api/pix/aspernatur'
payload = {
    "status": "PAGO"
}
headers = {
  'Authorization': 'Bearer {ACCESS_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PATCH', url, headers=headers, json=payload)
response.json()

Exemplo de response (204, Status atualizado):

Resposta em branco
 

Exemplo de response (404, Pix não encontrado):


{
    "codigo_erro": 123,
    "mensagem": "Pix não encontrado"
}
 

Exemplo de response (500, Erro interno):


{
    "codigo_erro": 13123123123,
    "mensagem": "Erro interno"
}
 

Request   

PATCH api/pix/{pixId}

Headers

Authorization      

Example: Bearer {ACCESS_TOKEN}

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

pixId   string   

Example: aspernatur

Body Parameters

status   string   

Example: PAGO

Must be one of:
  • PENDENTE
  • PAGO
  • EXPIRADO

Token de Acesso

Utilizamos o framework OAuth2 para auth

Obter token de acesso

Endpoint para obter access_token

Exemplo de request:
curl --request POST \
    "http://smartsafe.dyndns.tv:81/oauth/token" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"grant_type\": \"client_credentials\",
    \"client_id\": \"{CLIENT_ID}\",
    \"client_secret\": \"{CLIENT_SECRET}\"
}"
const url = new URL(
    "http://smartsafe.dyndns.tv:81/oauth/token"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "grant_type": "client_credentials",
    "client_id": "{CLIENT_ID}",
    "client_secret": "{CLIENT_SECRET}"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'http://smartsafe.dyndns.tv:81/oauth/token';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'grant_type' => 'client_credentials',
            'client_id' => '{CLIENT_ID}',
            'client_secret' => '{CLIENT_SECRET}',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'http://smartsafe.dyndns.tv:81//oauth/token'
payload = {
    "grant_type": "client_credentials",
    "client_id": "{CLIENT_ID}",
    "client_secret": "{CLIENT_SECRET}"
}
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Exemplo de response (200, access_token gerado):


{
    "token_type": "Bearer",
    "expires_in": 31536000,
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciO..."
}
 

Request   

POST /oauth/token

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

grant_type   string   

Example: client_credentials

client_id   string   

Example: {CLIENT_ID}

client_secret   string   

Example: {CLIENT_SECRET}

Response

Campos da response

token_type   string   

Tipo do token. Padrão: Bearer

expires_in   integer   

Segundos restantes para o token expirar

access_token   string   

Token de acesso