Skip to content

SPI API Reference

The SPI API endpoints handle instant payment operations. They are served by the Settlement Service gateway on port 4003, which proxies to the SPI Service on port 4002. All endpoints require JWT authentication.

Base URL: http://localhost:4003/api/v1

Payments

Initiate Payment

Create a new PIX instant payment.

POST /payments

Request Body:

json
{
  "amount": 150.00,
  "description": "Payment for services",
  "pix_key": "+5511999887766",
  "debtor": {
    "account_number": "123456",
    "branch": "0001",
    "name": "Maria Silva",
    "tax_id": "12345678901"
  },
  "idempotency_key": "unique-client-request-id-123"
}

Request Fields:

FieldTypeRequiredDescription
amountdecimalYesPayment amount in BRL (0.01 - 999,999,999.99)
descriptionstringNoPayment description (max 140 chars)
pix_keystringYes*Destination PIX key
creditor_accountobjectYes*Destination account (alternative to pix_key)
debtorobjectYesDebtor (sender) information
idempotency_keystringYesClient-generated unique request ID
prioritystringNoNORM (default) or HIGH

*Either pix_key or creditor_account must be provided.

Response: 201 Created

json
{
  "payment_id": "pay-a1b2c3d4",
  "end_to_end_id": "E1234567820240115120012345678901",
  "status": "PROCESSING",
  "amount": 150.00,
  "currency": "BRL",
  "description": "Payment for services",
  "debtor": {
    "ispb": "12345678",
    "branch": "0001",
    "account_number": "123456",
    "name": "Maria Silva",
    "tax_id": "***456***01"
  },
  "creditor": {
    "ispb": "87654321",
    "branch": "0002",
    "account_number": "654321",
    "name": "Jo** Si***",
    "tax_id": "***789***02"
  },
  "timestamps": {
    "created_at": "2024-01-15T12:00:00Z",
    "submitted_at": "2024-01-15T12:00:01Z"
  }
}

Payment Statuses:

StatusDescription
PROCESSINGPayment created and being processed
SUBMITTEDSent to BACEN SPI
CONFIRMEDConfirmed by BACEN (funds settled)
REJECTEDRejected by BACEN
RETURNEDPayment was returned/reversed
FAILEDProcessing error

Error Responses:

StatusCodeDescription
400INVALID_AMOUNTAmount outside allowed range
400INVALID_KEYPIX key format is invalid
404KEY_NOT_FOUNDPIX key not registered in DICT
409DUPLICATE_PAYMENTIdempotency key already used
422INSUFFICIENT_BALANCEDebtor account has insufficient funds
422ACCOUNT_BLOCKEDDebtor account is blocked
503SPI_UNAVAILABLEBACEN SPI is unreachable

Get Payment Details

Retrieve the full details and timeline of a payment.

GET /payments/:payment_id

Response: 200 OK

json
{
  "payment_id": "pay-a1b2c3d4",
  "end_to_end_id": "E1234567820240115120012345678901",
  "transaction_id": "TXN20240115ABC123",
  "status": "CONFIRMED",
  "amount": 150.00,
  "currency": "BRL",
  "description": "Payment for services",
  "debtor": {
    "ispb": "12345678",
    "branch": "0001",
    "account_number": "123456",
    "name": "Maria Silva",
    "tax_id": "12345678901"
  },
  "creditor": {
    "ispb": "87654321",
    "branch": "0002",
    "account_number": "654321",
    "name": "Joao Silva",
    "tax_id": "98765432102"
  },
  "timestamps": {
    "created_at": "2024-01-15T12:00:00Z",
    "submitted_at": "2024-01-15T12:00:01Z",
    "confirmed_at": "2024-01-15T12:00:02Z"
  },
  "settlement": {
    "window_id": "W20240115-03",
    "settled": true
  },
  "timeline": [
    {
      "event": "CREATED",
      "timestamp": "2024-01-15T12:00:00Z"
    },
    {
      "event": "KEY_RESOLVED",
      "timestamp": "2024-01-15T12:00:00.150Z",
      "details": "Destination resolved via DICT"
    },
    {
      "event": "SUBMITTED_TO_SPI",
      "timestamp": "2024-01-15T12:00:01Z",
      "details": "pacs.008 sent to BACEN"
    },
    {
      "event": "CONFIRMED",
      "timestamp": "2024-01-15T12:00:02Z",
      "details": "pacs.002 ACCC received"
    }
  ]
}

List Payments

Retrieve a paginated list of payments with filtering.

GET /payments

Query Parameters:

ParameterTypeDescription
statusstringFilter by payment status
directionstringinbound or outbound
start_datedatetimeStart of date range (ISO 8601)
end_datedatetimeEnd of date range (ISO 8601)
min_amountdecimalMinimum amount filter
max_amountdecimalMaximum amount filter
account_numberstringFilter by debtor or creditor account
end_to_end_idstringSearch by E2EID
pageintegerPage number (default: 1)
per_pageintegerItems per page (default: 20, max: 100)
sortstringSort field (default: created_at)
orderstringasc or desc (default: desc)

Response: 200 OK

json
{
  "data": [
    {
      "payment_id": "pay-a1b2c3d4",
      "end_to_end_id": "E1234567820240115120012345678901",
      "status": "CONFIRMED",
      "amount": 150.00,
      "direction": "outbound",
      "creditor_name": "Joao Silva",
      "created_at": "2024-01-15T12:00:00Z"
    }
  ],
  "meta": {
    "page": 1,
    "per_page": 20,
    "total": 15234,
    "total_pages": 762
  }
}

Initiate Return

Return a previously completed payment (full or partial).

POST /payments/:payment_id/return

Request Body:

json
{
  "amount": 150.00,
  "reason": "MD06",
  "description": "Refund requested by account holder"
}

Return Reason Codes:

CodeDescription
MD06Refund request by original sender
FR01Fraud
AC03Invalid creditor account number
AM09Wrong amount
BE08Wrong creditor
SL02Specific service by creditor agent
RR04Regulatory reason

Response: 201 Created

json
{
  "return_id": "ret-e5f6g7h8",
  "original_payment_id": "pay-a1b2c3d4",
  "original_e2e_id": "E1234567820240115120012345678901",
  "return_e2e_id": "D1234567820240116090087654321098",
  "amount": 150.00,
  "reason": "MD06",
  "status": "PROCESSING",
  "created_at": "2024-01-16T09:00:00Z"
}

WARNING

Returns must be initiated within 90 days of the original payment. For fraud-related returns (MED), different deadlines apply as defined by BACEN.


QR Codes

Generate Static QR Code

Create a reusable PIX QR code.

POST /qrcodes

Request Body:

json
{
  "type": "STATIC",
  "pix_key": "12345678901",
  "merchant_name": "Loja ABC",
  "merchant_city": "Sao Paulo",
  "amount": null,
  "description": "Pagamento na Loja ABC"
}

Response: 201 Created

json
{
  "qrcode_id": "qr-i9j0k1l2",
  "type": "STATIC",
  "emv_payload": "00020126580014br.gov.bcb.pix0111123456789015204000053039865802BR5909Loja ABC6009Sao Paulo62070503***6304A1B2",
  "image_url": "/qrcodes/qr-i9j0k1l2/image.png",
  "created_at": "2024-01-15T10:00:00Z"
}

Generate Dynamic QR Code

Create a single-use PIX QR code with a specific amount and expiration.

POST /qrcodes

Request Body:

json
{
  "type": "DYNAMIC",
  "pix_key": "12345678901",
  "merchant_name": "Loja ABC",
  "merchant_city": "Sao Paulo",
  "amount": 299.90,
  "description": "Pedido #12345",
  "expires_in": 3600,
  "payer": {
    "name": "Maria Silva",
    "tax_id": "12345678901"
  }
}

Response: 201 Created

json
{
  "qrcode_id": "qr-m3n4o5p6",
  "type": "DYNAMIC",
  "emv_payload": "00020126930014br.gov.bcb.pix2571api.example.com/pix/v2/cob/abc123...",
  "image_url": "/qrcodes/qr-m3n4o5p6/image.png",
  "location_url": "https://api.example.com/pix/v2/cob/abc123",
  "amount": 299.90,
  "expires_at": "2024-01-15T11:00:00Z",
  "created_at": "2024-01-15T10:00:00Z"
}

Get QR Code

GET /qrcodes/:qrcode_id

Returns the QR code details including current payment status for dynamic QR codes.


Position

Get Current Position

Retrieve the institution's current settlement position.

GET /position

Response: 200 OK

json
{
  "position": {
    "available": 50000000.00,
    "reserved": 1500000.00,
    "limit": 100000000.00,
    "utilization_percent": 50.0
  },
  "today": {
    "total_debits": 25000000.00,
    "total_credits": 23500000.00,
    "net": -1500000.00,
    "transaction_count": 45230
  },
  "last_updated": "2024-01-15T12:00:05Z"
}

Webhooks

Payment Status Webhook

When a payment status changes, the platform sends a webhook notification to registered URLs.

Webhook Payload:

json
{
  "event": "payment.confirmed",
  "payment_id": "pay-a1b2c3d4",
  "end_to_end_id": "E1234567820240115120012345678901",
  "status": "CONFIRMED",
  "amount": 150.00,
  "direction": "inbound",
  "timestamp": "2024-01-15T12:00:02Z"
}

Webhook Events:

EventDescription
payment.confirmedPayment successfully settled
payment.rejectedPayment rejected by BACEN
payment.returnedPayment return completed
payment.receivedInbound payment received
claim.receivedPortability/ownership claim received
infraction.receivedInfraction report received

Signature Verification:

Each webhook includes an X-Webhook-Signature header containing an HMAC-SHA256 signature of the request body:

X-Webhook-Signature: sha256=a1b2c3d4e5f6...

Verify the signature using your webhook secret to ensure the request originated from FluxiQ PIX.

FluxiQ PIX - Plataforma Brasileira de Pagamento Instantaneo