API reference · Orders

Upload Invoice XML - Marketplace

PUThttps://api.sandbox.cws.digital/partnerOrders/store/{id}/invoice

Description

Allows the origin store to attach the invoice XML to an order that was born in it.

The request body is the file itself, sent as binary content — the raw stream of the .xml bytes. It is not multipart/form-data, there is no form field and the XML does not go inside a JSON.

The invoice must be a real and valid NF-e.

The body and the rules are identical to those of the store route; what changes is the scope of who sends it.

Parameters

Path parameters

FieldTypeRequiredDescriptionValue
idintegerYes

Id of the partner order (partnerOrderId).

Request body

Content-Typeapplication/xmlRequired
FieldTypeRequiredDescription
stringNo

Business rules

What is read from the file

The platform reads the XML and extracts the access key, the number, the series, the issue date and the total amount of the invoice. That is why the file must be a real NF-e: a well-formed XML that is not an invoice does not carry this data.

The file is stored with the access key as its name.

Both usual formats are accepted — the processed XML, with the invoice envelope, and the XML with only the invoice block.

An empty file or one that is not valid XML is refused, and nothing is saved.

The order must have its payment approved

Only accepts an invoice on an order that has already passed payment approval. Before that, the request is refused and nothing is saved.

One invoice or several

By default the order keeps one file, and each upload replaces the previous one.

Stores configured for multiple invoices accumulate the files: each upload adds one more. The configuration belongs to the store and is done by CWS.

Responses

  • 200

    The data of the invoice attached to the order.

  • 401

    Missing, malformed or expired token.

  • 404

    The order does not exist or is not in your scope.

Try it

Sandbox

Language

Credentials

Access token: saved in this tab and used on every endpoint.

Each token only reaches the partner's own data and that of the branches with an authorized link.

Don't have sandbox credentials yet? See how to request them

Request

cURL
curl --request PUT \
  --url 'https://api.sandbox.cws.digital/partnerOrders/store/900201/invoice' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: application/xml' \
  --data '<?xml version="1.0" encoding="UTF-8"?>
<nfeProc versao="4.00">
  <NFe>
    <infNFe Id="NFe35260930424972000174550010000012341000012349">
      <ide><nNF>1234</nNF><serie>1</serie></ide>
    </infNFe>
  </NFe>
</nfeProc>'

Response

Click Try it to see the real response here, or pick a documented example: