Create & Update Tickets

These endpoints let you open a ticket, update its status, and post replies. All require a Bearer token (see Tickets Overview).

Create a ticket

POST /company/tickets

Opens a new support case for the authenticated company. The body varies by ticket type: shipment-based types reference a shipment_id, credit types reference credit_id, and type-specific fields go inside data as a JSON string. Credit line tickets (type 19) additionally require a documents array.

On success the ticket is created with status Pending (1), a history entry is recorded, the ticket is auto-assigned to a support agent, and (when a shipment_id is present) it is linked to any matching shipment incidence.

Body

PropTypeRequiredDefaultDescription
type_idinteger (≥ 1)yesTicket type ID. See Ticket types.
commentsstringoptional""Initial message from the customer. Recommended for context.
datastring (JSON)optionalJSON-stringified, type-specific fields stored as ticket variables.
shipment_idinteger (≥ 1)conditionalnullShipment reference. Required for shipment-based types (lost, damaged, delay, wrong address, overweight…).
credit_idinteger (≥ 1)conditionalnullCredit/recharge reference for credit-based types.
carrier_idinteger (≥ 1)optionalnullCarrier reference (e.g. carrier activation, type 2).
warehouse_package_idstringoptionalnullWarehouse package reference (PO box types). Accepts the package ID or the shipper name.
documentsarray<object>conditionalRequired for credit line (type 19). See sub-props below.

documents[] item

PropTypeRequiredDescription
field_idstring (max 50)yesIdentifier of the required document field.
keystringoptionalHuman-readable field key.
typestring — file | input | dateoptionalHow the value should be interpreted.
valuestring (nullable)optionalThe document URL, text value, or date.
curl --request POST \
  --url https://queries.envia.com/company/tickets \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "type_id": 4,
    "shipment_id": 123456,
    "comments": "The package never arrived.",
    "data": "{\"tracking_number\":\"1Z999AA10123456784\"}"
  }'

Response 200

{ "id": 987654 }
⚠️

Duplicate protection. Creating a ticket for the same company + shipment + type while an open ticket already exists (status Pending, Follow up, In review, or Declined) returns 409 Conflict with the message "A ticket has already been created for this shipment." Reuse the existing ticket instead.

Update a ticket

PUT /company/tickets/{ticket_id}

Updates a ticket's status (and optionally its variables and a comment). Customers can move a ticket to a limited set of statuses. Requests on terminal tickets (Accepted / Declined) are ignored.

Path parameters

ParamTypeRequiredDescription
ticket_idinteger (≥ 1)yesThe ticket ID.

Body

PropTypeRequiredDescription
ticket_status_idinteger — 1, 5, or 10yesTarget status: 1 Pending, 5 Follow up, 10 Claim in review.
commentsstringoptionalOptional message added with the update.
datastring (JSON)optionalReplaces the ticket variables with this JSON payload.
ℹ️

A transition to Follow up (5) is only honored from an In review (6) or Incomplete (4) ticket, and may be gated by an automated relevance check. Otherwise the ticket keeps its current status.

curl --request PUT \
  --url https://queries.envia.com/company/tickets/987654 \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "ticket_status_id": 5,
    "comments": "I have uploaded the missing document.",
    "data": "{\"tracking_number\":\"1Z999AA10123456784\"}"
  }'

Response 200

{ "data": true }

Add a comment

POST /company/tickets/{ticket_id}/comments

Posts a customer reply to the ticket thread. Blocked on terminal tickets (Accepted / Declined). If the ticket is In review (6), posting a comment can transition it to Follow up (5) so an agent re-engages.

Path parameters

ParamTypeRequiredDescription
ticket_idinteger (≥ 1)yesThe ticket ID.

Body

PropTypeRequiredDefaultDescription
commentstringoptional""The reply message text.
curl --request POST \
  --url https://queries.envia.com/company/tickets/987654/comments \
  --header 'Authorization: Bearer YOUR_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{ "comment": "Here is the additional information you requested." }'

Response 200

{ "data": true }