> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.sellercenter.pe/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.sellercenter.pe/_mcp/server.

# 2. Facturar y despachar

POST https://inretailqa.mysellercenter.com/sellercenter/api/v1/orders/{orderId}/invoice
Content-Type: application/json

**Paso 2.** Registra la factura/boleta y los datos de despacho.

- Estado requerido: `handling`.
- Estado resultante: `invoiced`.

### Body
| Campo | Tipo | Requerido | Descripción |
|---|---|---|---|
| `invoiceNumber` | string | Sí | Número del comprobante emitido (p. ej. `F001-00001234`). **Guárdalo**: lo necesitas para *Confirmar entrega*. |
| `courier` | string | Sí | Operador logístico que realiza la entrega. |
| `trackingNumber` | string | No | Código de seguimiento del envío. |
| `trackingUrl` | string (URL) | No | Enlace de seguimiento para el cliente. |
| `deliveryEstimate.date` | `YYYY-MM-DD` | Sí | Fecha estimada de entrega. |
| `deliveryEstimate.from` / `to` | `HH:mm` | Sí | Rango horario estimado. |
| `items[].id` | string | Sí | Id del SKU (de `items[].id` en el Detalle de orden). |
| `items[].quantity` | entero | Sí | Cantidad despachada. |

Después de este paso, sube el comprobante con **3. Subir comprobante de pago**.

Reference: https://developers.sellercenter.pe/referencia-de-la-api/ordenes/facturar-y-despachar

## Authentication

- `Authorization` header (bearer token, required) — `accessToken` obtenido en **Login**. Dura 24 horas.

## Servers

- `https://inretailqa.mysellercenter.com/sellercenter/api/v1` (QA, default)
- `https://inretail.mysellercenter.com/sellercenter/api/v1` (PRD)

## Request

### Path parameters

- `orderId` (string, required) — Número de orden en estado `handling`.

### Body (application/json)

This endpoint expects an object.

- `invoiceNumber` (string, optional)
- `courier` (string, optional)
- `trackingNumber` (string, optional)
- `trackingUrl` (string, optional)
- `deliveryEstimate` (OrdersOrderIdInvoicePostRequestBodyContentApplicationJsonSchemaDeliveryEstimate, optional)
- `items` (list of OrdersOrderIdInvoicePostRequestBodyContentApplicationJsonSchemaItemsItems, optional)

## Response

### 200

Orden facturada

## Errors

### 400 Bad Request Error

La orden no está en handling

- `message` (any, optional)

## Types

### OrdersOrderIdInvoicePostRequestBodyContentApplicationJsonSchemaDeliveryEstimate

- `date` (string, optional)
- `from` (string, optional)
- `to` (string, optional)

### OrdersOrderIdInvoicePostRequestBodyContentApplicationJsonSchemaItemsItems

- `id` (string, optional)
- `quantity` (double, optional)

## Examples

**Request**

```json
{
  "invoiceNumber": "F001-00001234",
  "courier": "Nombre del operador logístico",
  "trackingNumber": "TRK123456",
  "trackingUrl": "https://operador.pe/rastreo/TRK123456",
  "deliveryEstimate": {
    "date": "2026-11-05",
    "from": "09:00",
    "to": "18:00"
  },
  "items": [
    {
      "id": "1793043428985",
      "quantity": 1
    }
  ]
}
```

**Response**

```json
{}
```

**SDK Code**

```python Ordenes_facturarYDespachar_example
import requests

url = "https://inretailqa.mysellercenter.com/sellercenter/api/v1/orders/1673830516396-01/invoice"

payload = {
    "invoiceNumber": "F001-00001234",
    "courier": "Nombre del operador logístico",
    "trackingNumber": "TRK123456",
    "trackingUrl": "https://operador.pe/rastreo/TRK123456",
    "deliveryEstimate": {
        "date": "2026-11-05",
        "from": "09:00",
        "to": "18:00"
    },
    "items": [
        {
            "id": "1793043428985",
            "quantity": 1
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Ordenes_facturarYDespachar_example
const url = 'https://inretailqa.mysellercenter.com/sellercenter/api/v1/orders/1673830516396-01/invoice';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"invoiceNumber":"F001-00001234","courier":"Nombre del operador logístico","trackingNumber":"TRK123456","trackingUrl":"https://operador.pe/rastreo/TRK123456","deliveryEstimate":{"date":"2026-11-05","from":"09:00","to":"18:00"},"items":[{"id":"1793043428985","quantity":1}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Ordenes_facturarYDespachar_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://inretailqa.mysellercenter.com/sellercenter/api/v1/orders/1673830516396-01/invoice"

	payload := strings.NewReader("{\n  \"invoiceNumber\": \"F001-00001234\",\n  \"courier\": \"Nombre del operador logístico\",\n  \"trackingNumber\": \"TRK123456\",\n  \"trackingUrl\": \"https://operador.pe/rastreo/TRK123456\",\n  \"deliveryEstimate\": {\n    \"date\": \"2026-11-05\",\n    \"from\": \"09:00\",\n    \"to\": \"18:00\"\n  },\n  \"items\": [\n    {\n      \"id\": \"1793043428985\",\n      \"quantity\": 1\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Ordenes_facturarYDespachar_example
require 'uri'
require 'net/http'

url = URI("https://inretailqa.mysellercenter.com/sellercenter/api/v1/orders/1673830516396-01/invoice")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"invoiceNumber\": \"F001-00001234\",\n  \"courier\": \"Nombre del operador logístico\",\n  \"trackingNumber\": \"TRK123456\",\n  \"trackingUrl\": \"https://operador.pe/rastreo/TRK123456\",\n  \"deliveryEstimate\": {\n    \"date\": \"2026-11-05\",\n    \"from\": \"09:00\",\n    \"to\": \"18:00\"\n  },\n  \"items\": [\n    {\n      \"id\": \"1793043428985\",\n      \"quantity\": 1\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Ordenes_facturarYDespachar_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://inretailqa.mysellercenter.com/sellercenter/api/v1/orders/1673830516396-01/invoice")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"invoiceNumber\": \"F001-00001234\",\n  \"courier\": \"Nombre del operador logístico\",\n  \"trackingNumber\": \"TRK123456\",\n  \"trackingUrl\": \"https://operador.pe/rastreo/TRK123456\",\n  \"deliveryEstimate\": {\n    \"date\": \"2026-11-05\",\n    \"from\": \"09:00\",\n    \"to\": \"18:00\"\n  },\n  \"items\": [\n    {\n      \"id\": \"1793043428985\",\n      \"quantity\": 1\n    }\n  ]\n}")
  .asString();
```

```php Ordenes_facturarYDespachar_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://inretailqa.mysellercenter.com/sellercenter/api/v1/orders/1673830516396-01/invoice', [
  'body' => '{
  "invoiceNumber": "F001-00001234",
  "courier": "Nombre del operador logístico",
  "trackingNumber": "TRK123456",
  "trackingUrl": "https://operador.pe/rastreo/TRK123456",
  "deliveryEstimate": {
    "date": "2026-11-05",
    "from": "09:00",
    "to": "18:00"
  },
  "items": [
    {
      "id": "1793043428985",
      "quantity": 1
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Ordenes_facturarYDespachar_example
using RestSharp;

var client = new RestClient("https://inretailqa.mysellercenter.com/sellercenter/api/v1/orders/1673830516396-01/invoice");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"invoiceNumber\": \"F001-00001234\",\n  \"courier\": \"Nombre del operador logístico\",\n  \"trackingNumber\": \"TRK123456\",\n  \"trackingUrl\": \"https://operador.pe/rastreo/TRK123456\",\n  \"deliveryEstimate\": {\n    \"date\": \"2026-11-05\",\n    \"from\": \"09:00\",\n    \"to\": \"18:00\"\n  },\n  \"items\": [\n    {\n      \"id\": \"1793043428985\",\n      \"quantity\": 1\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Ordenes_facturarYDespachar_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "invoiceNumber": "F001-00001234",
  "courier": "Nombre del operador logístico",
  "trackingNumber": "TRK123456",
  "trackingUrl": "https://operador.pe/rastreo/TRK123456",
  "deliveryEstimate": [
    "date": "2026-11-05",
    "from": "09:00",
    "to": "18:00"
  ],
  "items": [
    [
      "id": "1793043428985",
      "quantity": 1
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://inretailqa.mysellercenter.com/sellercenter/api/v1/orders/1673830516396-01/invoice")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```