# 7. Generate Invoice

Generate Invoice Create an invoice PDF for a specific order identified by its orderId.
The response is returned as a downloadable PDF file (application/pdf).

The response contains the generated invoice as a PDF document.

Allowed only when order status:

  • is between confirmed up to order_completed

  • (or complaint_resolved if the order was complained).

Overview

Auth
HMAC Partner
Method
POST

# Path

https://partners-api.tocobagus.net/api/v1 /partner/stores/orders/{orderId}/documents/invoice

# Request

Query parameters: None.

# Required Headers

Header Example Description
x-signature bdbb8833fe43671e058b56dace75763a78a2edf8de7365afb6f534d750056e80 HMAC signature of the request, computed with the partner secret and x-timestamp (auth integrity).
x-partner-client-id ptnr_1s4UqMnO64 Partner identifier issued by Omni; used to locate the partner secret.
x-store-client-id store_NB5DgDcEoWEu Target store identifier under the partner account.
x-store-token stkn_Xfe-j_OKH5H2Xg66 Store access token for store-level authorization.
x-timestamp 1758100350458 UNIX epoch timestamp used when computing x-signature (replay protection).

# Request Payload

Request payload: None for this endpoint.

# Example Request

curl -X POST "http:///partner/stores/orders/d0e11047-acaf-468f-a325-3d2f5964f5ff/documents/invoice" \
  -H "Content-Type: application/json" \
  -H "x-signature: bdbb8833fe43671e058b56dace75763a78a2edf8de7365afb6f534d750056e80" \
  -H "x-partner-client-id: ptnr_1s4UqMnO64" \
  -H "x-store-client-id: store_NB5DgDcEoWEu" \
  -H "x-store-token: stkn_Xfe-j_OKH5H2Xg66" \
  -H "x-timestamp: 1758100350458" \
const qs = new URLSearchParams({});
const url = "http:///partner/stores/orders/d0e11047-acaf-468f-a325-3d2f5964f5ff/documents/invoice" + (qs.toString() ? "?" + qs.toString() : "");
const res = await fetch(url, {
  method: "POST",
  headers: {
  "x-signature": "bdbb8833fe43671e058b56dace75763a78a2edf8de7365afb6f534d750056e80",
  "x-partner-client-id": "ptnr_1s4UqMnO64",
  "x-store-client-id": "store_NB5DgDcEoWEu",
  "x-store-token": "stkn_Xfe-j_OKH5H2Xg66",
  "x-timestamp": "1758100350458"
}
});
const json = await res.json();
console.log(json);
qs := url.Values{}

u := "http:///partner/stores/orders/d0e11047-acaf-468f-a325-3d2f5964f5ff/documents/invoice"
if q := qs.Encode(); q != "" { u = u + "?" + q }
req, _ := http.NewRequest("POST", u, nil)
req.Header.Set("x-signature", "bdbb8833fe43671e058b56dace75763a78a2edf8de7365afb6f534d750056e80")
req.Header.Set("x-partner-client-id", "ptnr_1s4UqMnO64")
req.Header.Set("x-store-client-id", "store_NB5DgDcEoWEu")
req.Header.Set("x-store-token", "stkn_Xfe-j_OKH5H2Xg66")
req.Header.Set("x-timestamp", "1758100350458")
req.Header.Set("Content-Type","application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println(string(b))
var client = java.net.http.HttpClient.newHttpClient();
var req = java.net.http.HttpRequest.newBuilder()
    .uri(java.net.URI.create("http:///partner/stores/orders/d0e11047-acaf-468f-a325-3d2f5964f5ff/documents/invoice"))
    .header("Content-Type","application/json")
    .header("x-signature", "bdbb8833fe43671e058b56dace75763a78a2edf8de7365afb6f534d750056e80")
    .header("x-partner-client-id", "ptnr_1s4UqMnO64")
    .header("x-store-client-id", "store_NB5DgDcEoWEu")
    .header("x-store-token", "stkn_Xfe-j_OKH5H2Xg66")
    .header("x-timestamp", "1758100350458")
    .method("POST", java.net.http.HttpRequest.BodyPublishers.noBody())
    .build();
var res = client.send(req, java.net.http.HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());

# Responses

# Example Responses

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="invoice-sample.pdf"
Content-Length: 42137
%PDF-1.7
…(binary content omitted)…

Preview:

Download: invoice-sample.pdf

{
  "success": false,
  "error": {
    "code": "ORDER_021",
    "message": "Order status does not allow this operation",
    "details": {
      "timestamp": "2025-09-17T11:37:17.275Z",
      "hint": "Order is not eligible for invoice generation. Order substatus must be confirmed, waiting_pickup, waiting_drop_off, in_transit, delivered, or order_completed.",
      "context": {
        "orderId": "bce41d32-94f6-4250-8d69-caa3e3d10b79",
        "allowedSubstatuses": [
          "confirmed",
          "waiting_pickup",
          "waiting_drop_off",
          "in_transit",
          "delivered",
          "order_completed"
        ]
      }
    }
  },
  "requestId": "ae06ba6f-e8b1-4cb5-b6c9-5f02cf6f4712"
}
{
  "success": false,
  "error": {
    "code": "SYS_DEP_503",
    "message": "Service temporarily unavailable",
    "details": {
      "timestamp": "2025-09-17T12:22:54.052Z",
      "hint": "Service temporarily unavailable",
      "context": {
        "orderId": "d0e11047-acaf-468f-a325-3d2f5964f5ff",
        "operation": "invoice_generation",
        "errorCode": "ECONNREFUSED",
        "category": "connection_refused",
        "details": "External dependency refused the connection. The external service may be starting up, experiencing issues, or is temporarily unavailable."
      }
    }
  },
  "requestId": "a5646038-751d-4555-8a76-d96b7a97a0d1"
}

# Dictionary

None for this endpoint.

# Notes

None for this endpoint.