Documentação da API de Pacotes
Informações Gerais
Base URL: https://transamericausa.com.br/wp-json/onsolutions-package-api/v1
Autenticação: Bearer Token no cabeçalho Authorization
Autenticação
Para utilizar a API, primeiro é necessário gerar um token de acesso.
Endpoint: Gerar Token
URL: /token
Método: POST
Payload
{ "client_key": "sua_chave_cliente", "client_secret": "seu_secret_cliente" }
Resposta
{ "access_token": "string", "expires_in": 300 }
Observações
- O token gerado tem validade de 5 minutos
- É necessário gerar um novo token após a expiração
- O token deve ser utilizado no header Authorization de todas as requisições
Exemplo de uso do token
Authorization: Bearer seu_token_aqui
Códigos de Erro
Código HTTP | Descrição |
---|---|
401 | Credenciais inválidas ou token expirado |
400 | Dados obrigatórios faltando ou formato inválido |
Exemplos de Requisição
1. Gerando um token
curl -X POST \ 'https://transamericausa.com.br/wp-json/onsolutions-package-api/v1/token' \ -H 'Content-Type: application/json' \ -d '{ "client_key": "sua_chave_cliente", "client_secret": "seu_secret_cliente" }'
2. Gerando um pacote
curl -X POST \ 'https://transamericausa.com.br/wp-json/onsolutions-package-api/v1/generate-package' \ -H 'Authorization: Bearer seu_token' \ -H 'Content-Type: application/json' \ -d '{ "Shipment": { "reference_id": "374647-335909851", "service": "99994", "peso": "4.1000000", "length": "12.0000000", "width": "8.0000000", "height": "15.0000000", "measure_unit": "lb" }, "Sender": { "name": "John Doe", "address": "123 Sender St", "zip": "33386", "city": "Miami", "state": "FL", "country": "US", "email": "[email protected]", "phone": "1234567890" }, "Receiver": { "name": "Maria Silva", "address": "456 Receiver St", "zip": "01234567", "city": "São Paulo", "state": "SP", "country": "BR", "email": "[email protected]", "phone": "5511999999999" }, "ShipmentVolumes": [ { "sku": "12345", "description": "Produto Exemplo", "quantity": "1", "price": "99.00" } ] }'
Endpoint: Generate Package
URL: /generate-package
Método: POST
Headers Necessários
Authorization: Bearer seu_token Content-Type: application/json
Estrutura do Payload
{ "Shipment": { "reference_id": "string", "service": "string", "peso": "string", "length": "string", "width": "string", "height": "string", "freight": number, "insurance": number, "website": "string", "measure_unit": "string" }, "Sender": { "name": "string", "last_name": "string", "website": "string", "address": "string", "zip": "string", "city": "string", "state": "string", "country": "string", "email": "string", "phone": "string", "social_security": "string" }, "Receiver": { "name": "string", "last_name": "string", "cpf": "string", "email": "string", "phone": "string", "number": "string", "address": "string", "complement": "string", "zip": "string", "city": "string", "state": "string", "country": "string" }, "ShipmentVolumes": [ { "sku": "string", "description": "string", "quantity": "string", "price": "string" } ] }
Campos Obrigatórios
Shipment
- reference_id
- service
- peso
- length
- width
- height
- measure_unit
Sender
- name
- address
- zip
- city
- state
- country
- phone
Receiver
- name
- address
- zip
- city
- state
- country
- phone
ShipmentVolumes (cada item)
- sku
- description
- quantity
- price
Resposta
{ "success": boolean, "message": "string" }