Ir para o conteúdo

Quais são os eventos enviados pelos webhooks

Informação

Atualmente, não existe a possibilidade de escolher quais eventos serão enviados. Assim, todos eles são disparados pelo sistema.

Para melhor organização, separamos os eventos por "entidade.ação". Em um exemplo prático, um evento pode ser "package.created".

Confira, abaixo, outros exemplos de eventos:

Entidade Evento Descrição
package created Evento enviado quando um pacote é criado
package updated Evento enviado quando um pacote é atualizado
package deleted Evento enviado quando um pacote é deletado
event created Evento enviado quando um atualização sobre o pacote é criada

Eventos de criação

Nos eventos de criação, o SaiuPraEntrega envia o estado atual do objeto junto a algumas informações extras, como no exemplo abaixo:

{
  "event": "package.created",
  "data": {
    "id": 2,
    "type": "package",
    "current": {
      "description": "Pedido de teste",
      "customer_name": "Cliente 1",
      "customer_email": "[email protected]",
      "customer_phone": "+55912345678",
      "tracking_code": "OS027108981BR",
      "tracking_url": "https://localhost/r/lNYJzAkbOa",
      "shipping_company": "correios",
      "fiscal_invoice_code": null,
      "fiscal_invoice_key": null,
      "fiscal_invoice_series": null,
      "created_at": "2022-02-02T23:13:40+00:00",
      "deleted_at": null,
      "finished_at": null,
      "address_not_found_at": null,
      "arrived_withdrawal_at": null,
      "damaged_at": null,
      "delivered_at": null,
      "delivered_to_sender_at": null,
      "delivery_attempt_failed_at": null,
      "fulfilled_at": null,
      "last_forwarding_at": null,
      "misplaced_at": null,
      "refused_at": null,
      "returned_at": null,
      "scheduled_at": null,
      "taxed_at": null,
      "waiting_tax_payment_at": null,
      "last_track_at": null,
      "last_track_attempt_at": null,
      "items": [],
      "destination_address": null
    },
    "previous": null,
    "changes": []
  }
}

Eventos de atualização

Nos eventos de atualização, o SaiuPraEntrega envia o estado atual do objeto e o anterior, junto a algumas informações extras, como no exemplo abaixo:

{
  "event": "package.updated",
  "data": {
    "id": 2,
    "type": "package",
    "current": {
      "description": "Pedido de teste",
      "customer_name": "Cliente 1",
      "customer_email": "[email protected]",
      "customer_phone": "+55912345678",
      "tracking_code": "OS027108981BR",
      "tracking_url": "https://localhost/r/lNYJzAkbOa",
      "shipping_company": "correios",
      "fiscal_invoice_code": null,
      "fiscal_invoice_key": null,
      "fiscal_invoice_series": null,
      "created_at": "2022-02-02T23:13:40+00:00",
      "deleted_at": null,
      "finished_at": "2021-11-24T20:53:45+00:00",
      "address_not_found_at": null,
      "arrived_withdrawal_at": null,
      "damaged_at": null,
      "delivered_at": "2021-11-24T20:53:45+00:00",
      "delivered_to_sender_at": null,
      "delivery_attempt_failed_at": null,
      "fulfilled_at": "2021-11-22T21:13:13+00:00",
      "last_forwarding_at": "2021-11-23T17:36:02+00:00",
      "misplaced_at": null,
      "refused_at": null,
      "returned_at": null,
      "scheduled_at": null,
      "taxed_at": null,
      "waiting_tax_payment_at": null,
      "last_track_at": null,
      "last_track_attempt_at": "2022-02-02T23:13:40+00:00",
      "items": [],
      "destination_address": null
    },
    "previous": {
      "description": "Pedido de teste",
      "customer_name": "Cliente 1",
      "customer_email": "[email protected]",
      "customer_phone": "+55912345678",
      "tracking_code": "OS027108981BR",
      "tracking_url": "https://localhost/r/lNYJzAkbOa",
      "shipping_company": "correios",
      "fiscal_invoice_code": null,
      "fiscal_invoice_key": null,
      "fiscal_invoice_series": null,
      "created_at": "2022-02-02T23:13:40+00:00",
      "deleted_at": null,
      "finished_at": "2021-11-24T20:36:15+00:00",
      "address_not_found_at": null,
      "arrived_withdrawal_at": null,
      "damaged_at": null,
      "delivered_at": "2021-11-24T20:36:15+00:00",
      "delivered_to_sender_at": null,
      "delivery_attempt_failed_at": null,
      "fulfilled_at": "2021-11-22T21:13:13+00:00",
      "last_forwarding_at": "2021-11-23T17:36:02+00:00",
      "misplaced_at": null,
      "refused_at": null,
      "returned_at": null,
      "scheduled_at": null,
      "taxed_at": null,
      "waiting_tax_payment_at": null,
      "last_track_at": null,
      "last_track_attempt_at": "2022-02-02T23:13:40+00:00",
      "items": [],
      "destination_address": null
    },
    "changes": [
      "delivered_at",
      "finished_at"
    ]
  }
}

Eventos de deleção

Nos eventos de deleção, o SaiuPraEntrega envia o estado anterior do objeto, junto a algumas informações extras, como no exemplo abaixo:

{
  "event": "package.deleted",
  "data": {
    "id": 2,
    "type": "package",
    "current": null,
    "previous": {
      "description": "Pedido de teste",
      "customer_name": "Cliente 1",
      "customer_email": "[email protected]",
      "customer_phone": "+55912345678",
      "tracking_code": "OS027108981BR",
      "tracking_url": "https://localhost/r/lNYJzAkbOa",
      "shipping_company": "correios",
      "fiscal_invoice_code": null,
      "fiscal_invoice_key": null,
      "fiscal_invoice_series": null,
      "created_at": "2022-02-02T23:13:40+00:00",
      "deleted_at": "2022-02-02T23:20:52+00:00",
      "finished_at": "2021-11-24T20:53:45+00:00",
      "address_not_found_at": null,
      "arrived_withdrawal_at": null,
      "damaged_at": null,
      "delivered_at": "2021-11-24T20:53:45+00:00",
      "delivered_to_sender_at": null,
      "delivery_attempt_failed_at": null,
      "fulfilled_at": "2021-11-22T21:13:13+00:00",
      "last_forwarding_at": "2021-11-23T17:36:02+00:00",
      "misplaced_at": null,
      "refused_at": null,
      "returned_at": null,
      "scheduled_at": null,
      "taxed_at": null,
      "waiting_tax_payment_at": null,
      "last_track_at": "2022-02-02T23:13:56+00:00",
      "last_track_attempt_at": "2022-02-02T23:13:40+00:00",
      "items": [],
      "destination_address": null
    },
    "changes": []
  }
}

Note que o campo "changes" e "current" sempre estarão vazios no evento de deleção.

Evento de criação de evento do pacote

Nos eventos de criação de evento do pacote, o SaiuPraEntrega envia o estado do novo evento do objeto junto com as informações do objeto, como no exemplo abaixo:

{
  "event": "event.created",
  "data": {
    "id": 13,
    "type": "event",
    "current": {
      "type": "BDE",
      "status": "01",
      "unit_name": "CDD ITANHAEM",
      "unit_address": {
        "street": "AVENIDA MOZART PINHEIRO DE LUCENA",
        "number": "1580",
        "district": "VILA VELHA",
        "city": "FORTALEZA",
        "state": "CE",
        "zip_code": "60.347-971"
      },
      "description": "Objeto entregue ao destinatário",
      "description_translated": "Objeto entregue ao destinatário",
      "ignore_last_event": false,
      "is_address_not_found": false,
      "is_awaiting_withdrawal": false,
      "is_delivery_attempt_failed": false,
      "is_out_for_delivery": false,
      "is_waiting_tax_payment": false,
      "was_damaged": false,
      "was_delivered": true,
      "was_delivered_to_sender": false,
      "was_forwarded": false,
      "was_fulfilled": false,
      "was_misplaced": false,
      "was_refused": false,
      "was_returned": false,
      "was_scheduled": false,
      "was_taxed": false,
      "happened_at": "2021-11-24T20:36:15+00:00",
      "created_at": "2022-02-02T23:13:51+00:00",
      "package": {
        "id": 2,
        "description": "Pedido de teste",
        "customer_name": "Cliente 1",
        "customer_email": "[email protected]",
        "customer_phone": "+55912345678",
        "tracking_code": "OS027108981BR",
        "tracking_url": "https://localhost/r/lNYJzAkbOa",
        "shipping_company": "correios",
        "fiscal_invoice_code": null,
        "fiscal_invoice_key": null,
        "fiscal_invoice_series": null,
        "created_at": "2022-02-02T23:13:40+00:00",
        "deleted_at": null,
        "finished_at": null,
        "address_not_found_at": null,
        "arrived_withdrawal_at": null,
        "damaged_at": null,
        "delivered_at": null,
        "delivered_to_sender_at": null,
        "delivery_attempt_failed_at": null,
        "fulfilled_at": "2021-11-22T21:13:13+00:00",
        "last_forwarding_at": "2021-11-23T17:36:02+00:00",
        "misplaced_at": null,
        "refused_at": null,
        "returned_at": null,
        "scheduled_at": null,
        "taxed_at": null,
        "waiting_tax_payment_at": null,
        "last_track_at": null,
        "last_track_attempt_at": "2022-02-02T23:13:40+00:00",
        "items": [],
        "destination_address": null
      }
    },
    "previous": null,
    "changes": []
  }
}