Skip to main content

Your first PIX charge

Follow this guide to create your first PIX charge in a few minutes.
1

Get your credentials

Open the Safefy Dashboard and create an API credential.You will receive:
  • clientId - Public identifier of your application
  • clientSecret - Secret key (shown only once, keep it safe!)
2

Generate an access token

With your credentials, request a JWT token:
curl -X POST https://api-payment.safefypay.com.br/v1/auth/token \
  -H "Content-Type: application/json" \
  -d '{
    "grantType": "client_credentials",
    "clientId": "pk_sandbox_your_client_id",
    "clientSecret": "sk_sandbox_your_client_secret"
  }'
Response:
{
  "data": {
    "accessToken": "eyJhbGciOiJIUzI1NiIs...",
    "tokenType": "Bearer",
    "expiresIn": 3600
  }
}
3

Create a PIX charge

Use the token to create your first charge:
curl -X POST https://api-payment.safefypay.com.br/v1/transactions \
  -H "Authorization: Bearer {your_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "method": "pix",
    "amount": 1000,
    "currency": "BRL",
    "description": "My first charge",
    "callbackUrl": "https://yoursite.com/webhook"
  }'
Response:
{
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "Pending",
    "amount": 1000,
    "pix": {
      "qrCode": "data:image/png;base64,...",
      "copyAndPaste": "00020126580014br.gov.bcb.pix..."
    }
  }
}
4

Receive the payment

When the payment is confirmed, you will receive a webhook at the configured URL:
{
  "event": "transaction.completed",
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "Completed",
    "amount": 1000,
    "completedAt": "2024-01-15T10:30:00Z"
  }
}

Next steps