Exemplos requisições

Solicitação de consulta de débitos

curl --location 'https://api.b2b.usezapay.com.br/v2/vehicle/debts' \
--header 'Authorization: Basic BASIC_AUTH_BASE64' \
--header 'Content-Type: application/json' \
--data '{
  "license_plate": "ABC1234"
}'

Resultado da solicitação de consulta de débitos

{
  "request_id": "653bde82b520d9659513988b"
}

Webhook informando que encontrou débitos para o veículo informado

{
  "id": "B1234",
  "event": "vehicle_debt_found",
  "webhook": {
    "id": "B1234",
    "resource": "vehicle_debt",
    "version": "v2"
  },
  "data": {
    "debts": [
      {
        "id": "8J7SH08Q74Q0",
        "fine": null,
        "ipva": null,
        "type": "licensing",
        "year": "2023",
        "title": "LICENCIAMENTO",
        "amount": 160.23,
        "status": null,
        "distinct": [],
        "due_date": "2023-11-30",
        "interest": null,
        "required": null,
        "depends_on": [
          "MSIP7G9Z1G06"
        ],
        "is_expired": null,
        "description": "Licenciamento - 2023",
        "has_discount": null,
        "expiration_date": null,
        "discount_percentage": null,
        "value_without_discount": null
      },
      {
        "id": "MSIP7G9Z1G06",
        "fine": null,
        "ipva": null,
        "type": "ipva-unique",
        "year": "2023",
        "title": "IPVA",
        "amount": 1438.03,
        "status": null,
        "distinct": [],
        "due_date": "2023-02-10",
        "interest": null,
        "required": null,
        "depends_on": [
          "8J7SH08Q74Q0"
        ],
        "is_expired": null,
        "description": "IPVA Único 2023",
        "has_discount": null,
        "expiration_date": null,
        "discount_percentage": null,
        "value_without_discount": null
      }
    ],
    "protocol": "AAAAAZP",
    "request_id": "BBBBZP",
    "vehicle": {
        "license_plate": "ABC1234",
        "renavam": "11111111111"
    },
    "customer": {},
    "has_open_payment": false
  }
}

Webhook informando que o veículo não possui débitos

{
  "id": "B1234",
  "event": "vehicle_debt_not_found",
  "webhook": {
    "id": "B1234",
    "resource": "vehicle_debt",
    "version": "v2"
  },
  "data": {
    "detail": "Não foram localizados débitos para o veículo informado.",
    "code": "vehicle_debt_bureau_debts_not_found",
    "protocol": "U4L2S5ZP",
    "request_id": "65fc81c40a4390c36134808d",
    "vehicle": {
            "license_plate": "ABC1234",
            "renavam": "1111111111",
            "chassis": "1111111111111",
            "document": "11111111111",
            "owner": null,
            "model": null,
            "color": null,
            "fabrication_year": null,
            "model_year": null
        }
  }
}

Webhook de veículo não encontrado

{
  "id": "B1234",
  "event": "vehicle_not_found",
  "webhook": {
    "id": "B1234",
    "resource": "vehicle_debt",
    "version": "v2"
  },
  "data": {
    "detail": "A requisição foi cancelada porque o veículo não foi encontrado.",
    "code": "vehicle_debt_bureau_vehicle_not_found",
    "protocol": "U4L2S5ZP",
    "request_id": "65fc81c40a4390c36134808d",
    "vehicle": {
            "license_plate": "ABC1234",
            "renavam": "1111111111",
            "chassis": "1111111111111",
            "document": "11111111111",
            "owner": null,
            "model": null,
            "color": null,
            "fabrication_year": null,
            "model_year": null
        }
  }
}

Webhook em caso de serviço de pesquisa indisponível

Na primeira pesquisa será feita 2 vezes a requisição para as fontes de dados daquele estado. Cada tentativa tem a duração entre elas de 10 minutos, ou seja, totalizando 20 minutos de espera na primeira pesquisa em caso de indisponibilidade da fonte de dados. Após isso, será enviado via webhook a mensagem abaixo indicando que em 24 horas será refeita a pesquisa e será enviada via webhook em caso de sucesso ou fracasso. Portanto, temos na primeira pesquisa duas tentativas para tentar conseguir os débitos e em caso de erro será enviado um webhook indicando que foi agendado uma nova pesquisa para 24h depois, e será enviado a resposta ao webhook.

{
  "id": "db489015-bfa6-4e50-83ee-554f38573b2d",
  "status": "pending",
  "event": "vehicle_debt_unavailable",
  "data": {
    "code": "vehicle_debt_bureau_unavailable",
    "request_id": "6601b78e3e7c0c91b5c9a66f",
    "vehicle": {
      "license_plate": "ABC1234",
      "renavam": "11111111111",
      "chassis": "111111111111111",
      "document": "11111111111",
      "owner": null,
      "model": null,
      "color": null,
      "fabrication_year": null,
      "model_year": null
    },
    "protocol": "6R7HJZZP",
    "detail": "Não foi possível realizar a pesquisa! Será feita a re-tentativa novamente em 24h."
  },
  "webhook": {
    "id": "d66c3ce5-ac5a-4604-8629-38eb86c7d2e6",
    "resource": "vehicle_debt",
    "version": "v2"
  }
}

Webhook em caso de erro

{
  "id": "B1234",
  "event": "vehicle_debt_search_error",
  "webhook": {
    "id": "B1234",
    "resource": "vehicle_debt",
    "version": "v2"
  },
  "data": {
    "detail": "A requisição foi cancelada porque o veículo está bloqueado.",
    "code": "vehicle_debt_bureau_vehicle_blocked",
    "protocol": "U4L2S5ZP",
    "request_id": "65fc81c40a4390c36134808d",
    "vehicle": {
            "license_plate": "ABC1234",
            "renavam": "1111111111",
            "chassis": "1111111111111",
            "document": "11111111111",
            "owner": null,
            "model": null,
            "color": null,
            "fabrication_year": null,
            "model_year": null
        }
  }
}

Webhook em caso de falha na obtenção dos dados complementares

{
  "id": "B1234",
  "event": "vehicle_enriched_partially",
  "webhook": {
    "id": "B1234",
    "resource": "vehicle_debt",
    "version": "v2"
  },
  "data": {
    "protocol": "U4L2S5ZP",
    "request_id": "65fc81c40a4390c36134808d",
    "vehicle": {
            "license_plate": "ABC1234",
            "renavam": "1111111111",
            "chassis": "1111111111111",
            "document": "11111111111",
            "owner": null,
            "model": null,
            "color": null,
            "fabrication_year": null,
            "model_year": null
        },
    "detail": "A requisição não foi concluída por falta de dados adicionais.",
    "code": "vehicle_enriched_partially",
    "required_fields": [
      "state",
      "renavam",
      "document"
    ]
  }
}

Request para complementar a pesquisa com dados adicionais do veículo

curl --location 'https://api.b2b.usezapay.com.br/v2/vehicle/debts' \
--header 'Authorization: JWT TOKEN_JWT_VALIDO' \
--header 'Content-Type: application/json' \
--data '{
  "license_plate": "ABC1234",
  "renavam": "12345678901",
  "document": "12345678901",
  "state": "SP",
  "request_id": "653bde82b520d9659513988b"
}'

Request para listar o histórico de webhooks enviados

curl --location 'https://api.b2b.usezapay.com.br/v2/webhook/{hook_id}/events/' \
--header 'Authorization: JWT TOKEN_JWT_VALIDO' \
--header 'Content-Type: application/json' \
--data '{
    "events": [
        "vehicle_not_found"
    ],
    "created_at": "string",
    "status": "pending"
}'

Resultado da listagem de histórico de webhooks enviados

Na listagem de items os campos:

  • Items: Onde será listado todos os eventos enviados para aquele webhook;
  • Page: Número da página do paginamento do resultado dos eventos;
  • Pages: Quantidade geral de páginas do resultado;
  • size: Quantidade de items por página de resultado;
  • Total: Quantidade de items que aquela página possui.
{
  "items": [
    {
      "id": "B1234",
      "event": "vehicle_debt_found",
      "webhook": {
        "id": "B1234",
        "resource": "vehicle_debt",
        "version": "v2"
      },
      "status": "sent",
      "data": {
        "debts": [
          {
            "id": "8J7SH08Q74Q0",
            "fine": null,
            "ipva": null,
            "type": "licensing",
            "year": "2023",
            "title": "LICENCIAMENTO",
            "amount": 160.23,
            "status": null,
            "distinct": [],
            "due_date": "2023-11-30",
            "interest": null,
            "required": null,
            "depends_on": [
              "MSIP7G9Z1G06"
            ],
            "is_expired": null,
            "description": "Licenciamento - 2023",
            "has_discount": null,
            "expiration_date": null,
            "discount_percentage": null,
            "value_without_discount": null
          },
          {
            "id": "MSIP7G9Z1G06",
            "fine": null,
            "ipva": null,
            "type": "ipva-unique",
            "year": "2023",
            "title": "IPVA",
            "amount": 1438.03,
            "status": null,
            "distinct": [],
            "due_date": "2023-02-10",
            "interest": null,
            "required": null,
            "depends_on": [
              "8J7SH08Q74Q0"
            ],
            "is_expired": null,
            "description": "IPVA Único 2023",
            "has_discount": null,
            "expiration_date": null,
            "discount_percentage": null,
            "value_without_discount": null
          }
        ],
        "protocol": "AAAAAZP",
        "request_id": "BBBBZP",
        "vehicle": {
            "license_plate": "ABC1234",
            "renavam": "11111111111"
        },
        "customer": {},
        "has_open_payment": false
      },
      "attempts": [
        {
          "attempt": 2,
          "created_at": "2023-10-24T15:44:04.506308",
          "status": "sent",
          "server_response": {
            "http_status_code": 200,
            "headers": {
              "Access-Control-Allow-Credentials": true,
              "Access-Control-Allow-Origin": "*",
              "Access-Control-Expose-Headers": "filename",
              "Content-Type": "application/json",
              "Date": "Fri, 24 Nov 2023 15:44:15 GMT",
              "Content-Length": "33",
              "Connection": "keep-alive"
            },
            "body": {
              "msg": "Ok"
            }
          }
        },
        {
          "attempt": 1,
          "created_at": "2023-10-24T15:44:04.506308",
          "status": "failed",
          "server_response": {
            "http_status_code": 500,
            "headers": {
              "Access-Control-Allow-Credentials": true,
              "Access-Control-Allow-Origin": "*",
              "Access-Control-Expose-Headers": "filename",
              "Content-Type": "application/json",
              "Date": "Fri, 24 Nov 2023 15:44:15 GMT",
              "Content-Length": "33",
              "Connection": "keep-alive"
            },
            "body": {
              "msg": "Error"
            }
          }
        }
      ]
    }
  ],
  "total": 1,
  "page": 1,
  "size": 1,
  "pages": 1
}

Request para reenviar um determinado webhook

curl --location 'https://api.b2b.usezapay.com.br/v2/webhook/{hook_id}/events/retry' \
--header 'Authorization: JWT TOKEN_JWT_VALIDO' \
--header 'Content-Type: application/json' \
--data '{
  "event_id": "event_12345"
}'

Resultado da retentativa de envio de um webhook

{
  "id": "B1234",
  "event": "vehicle_debt_found",
  "webhook": {
    "id": "B1234",
    "resource": "vehicle_debt",
    "version": "v2"
  },
  "status": "sent",
  "data": {
    "debts": [
      {
        "id": "8J7SH08Q74Q0",
        "fine": null,
        "ipva": null,
        "type": "licensing",
        "year": "2023",
        "title": "LICENCIAMENTO",
        "amount": 160.23,
        "status": null,
        "distinct": [],
        "due_date": "2023-11-30",
        "interest": null,
        "required": null,
        "depends_on": [
          "MSIP7G9Z1G06"
        ],
        "is_expired": null,
        "description": "Licenciamento - 2023",
        "has_discount": null,
        "expiration_date": null,
        "discount_percentage": null,
        "value_without_discount": null
      },
      {
        "id": "MSIP7G9Z1G06",
        "fine": null,
        "ipva": null,
        "type": "ipva-unique",
        "year": "2023",
        "title": "IPVA",
        "amount": 1438.03,
        "status": null,
        "distinct": [],
        "due_date": "2023-02-10",
        "interest": null,
        "required": null,
        "depends_on": [
          "8J7SH08Q74Q0"
        ],
        "is_expired": null,
        "description": "IPVA Único 2023",
        "has_discount": null,
        "expiration_date": null,
        "discount_percentage": null,
        "value_without_discount": null
      }
    ],
    "protocol": "AAAAAZP",
    "request_id": "BBBBZP",
    "vehicle": {
        "license_plate": "ABC1234",
        "renavam": "11111111111"
    },
    "customer": {},
    "has_open_payment": false
  },
  "attempts": [
    {
      "attempt": 3,
      "created_at": "2023-12-06T13:55:02.301309",
      "status": "sent",
      "server_response": {
        "http_status_code": 200,
        "headers": {
          "Access-Control-Allow-Credentials": true,
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Expose-Headers": "filename",
          "Content-Type": "application/json",
          "Date": "Fri, 06 Dec 2023 13:55:03 GMT",
          "Content-Length": "33",
          "Connection": "keep-alive"
        },
        "body": {
          "msg": "Ok"
        }
      }
    },
    {
      "attempt": 2,
      "created_at": "2023-10-24T15:44:04.506308",
      "status": "sent",
      "server_response": {
        "http_status_code": 200,
        "headers": {
          "Access-Control-Allow-Credentials": true,
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Expose-Headers": "filename",
          "Content-Type": "application/json",
          "Date": "Fri, 24 Nov 2023 15:44:15 GMT",
          "Content-Length": "33",
          "Connection": "keep-alive"
        },
        "body": {
          "msg": "Ok"
        }
      }
    },
    {
      "attempt": 1,
      "created_at": "2023-10-24T15:44:04.506308",
      "status": "failed",
      "server_response": {
        "http_status_code": 500,
        "headers": {
          "Access-Control-Allow-Credentials": true,
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Expose-Headers": "filename",
          "Content-Type": "application/json",
          "Date": "Fri, 24 Nov 2023 15:44:15 GMT",
          "Content-Length": "33",
          "Connection": "keep-alive"
        },
        "body": {
          "msg": "Error"
        }
      }
    }
  ]
}