# xmlvalid in Postman

Source: https://xmlvalid.com/docs/integrations/postman

> Every request of the API with real responses: send your first validation in a minute, then turn it into code.

The [xmlvalid collection](https://xmlvalid.com/docs/api/postman.json) has a request for each endpoint of the [API](https://xmlvalid.com/docs/api), grouped as Validate, Results and Account, each with a description and example responses recorded from the real API.

## Get the collection

Open the [xmlvalid workspace](https://www.postman.com/xml-valid/xmlvalid-api) on the Postman API Network and **fork** the collection into your own workspace: you get updates when we publish them. Or import it:

1. In Postman, choose **Import**.
2. Paste the link `https://xmlvalid.com/docs/api/postman.json`, or download the file and drop it in.

Prefer generating it yourself? Postman also imports the [OpenAPI description](https://xmlvalid.com/docs/api/openapi.yaml), but the collection adds the examples, the variables and the scripts below.

## Add your API key

1. Make a key under [Dashboard → API keys](https://xmlvalid.com/dashboard/api) (a free account includes 100 validations a month).
2. Select the collection, open **Variables** and paste the key into the **Current value** of `apiKey`. Current values stay on your machine and are not shared when you share the collection.
3. Save. Every request sends it as `Authorization: Bearer xv_…`, set once on the collection.

Using several keys, or a staging server? Put `apiKey` and `baseUrl` in a Postman environment instead; an environment's values take precedence over the collection's.

## Your first validation

Open **Validate → Validate an e-invoice by URL** and send it. Its body asks xmlvalid to fetch an example Peppol invoice and check it with `schema: auto`:

```json
{
  "url": "https://xmlvalid.com/schemas/peppol-bis-3-invoice/example",
  "schema": "auto",
  "wait": 30
}
```

The answer is the finished validation with `"valid": true`. Then open **Validate XML sent as the body**: the body is the same invoice. Change the amount in `cbc:PayableAmount` and send it again to see business rule BR-CO-16 fail, with its line and a link to [the rule's page](https://xmlvalid.com/rules/BR-CO-16). The request's **Examples** show both answers.

If a validation takes longer than `wait` seconds, the API answers `202` with the status `queued` or `running`: send **Results → Fetch a validation** until it is `done`.

## Files and your own schemas

- **Validate a file**: in **Body → form-data**, choose a file for `document`. XML, gzip, ZIP archives and Factur-X or ZUGFeRD PDFs are accepted.
- **Validate against your own schema**: a file for `document` and an XSD, DTD or RelaxNG file for `schema_file`. For a schema with imports, [save it](https://xmlvalid.com/dashboard/schemas) once and pass its name (`my-12`) as `schema` instead.
- **Validate with your own Schematron rules**: a `.sch` file for `rules_file`, run after the schema check.

**Account → List schemas** gives the name of every catalog schema and of your saved ones.

## Results and reports

Each validate request saves the id of its validation in the collection variable `validationId` (see its **Scripts** tab), so the requests under **Results** work right after it: fetch it, cancel it, get its HTML report, or share it as a public link (Pro). The Postman Console shows a one-line summary of each run.

## From Postman to code

When a request does what you need, open its **Code** panel (the `</>` icon) for the same call in curl, Python, JavaScript, PHP, Java, C# and more. For the response fields and the error codes, see the [API reference](https://xmlvalid.com/docs/api); for CI and scripts, the [command-line client](https://xmlvalid.com/docs/ci) does the requests and the polling for you.

## Run it in CI with Newman

[Newman](https://www.npmjs.com/package/newman) runs the collection from the command line, for a smoke test of your key and quota:

```bash
npx newman run https://xmlvalid.com/docs/api/postman.json \
  --env-var apiKey=$XMLVALID_API_KEY \
  --folder Account
```

The requests that send a file need one chosen in Postman, so leave them out of unattended runs.
