Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. By signing up you are subscribing to the APIs.io and API Evangelist
newsletters — you can unsubscribe from any issue. See our
Privacy Policy and Terms.
openapi: 3.2.0
info:
title: Two Order Invoice API
version: '1.0'
description: 'This API is for creating orders connected to an online purchase through your solution.
The API also functions as a central building block when using other Two APIs, e.g. Marketplace API, and Trade Account Onboarding API.
Specifically, the API enables you to:
- Check whether a buyer is accepted for credit before placing the order (Order intent)
- Create orders
- Fulfil orders (Send invoice from Two)
- Edit orders
- Cancel orders
- Refund orders (Send credit note)
- Download invoice
Below you will find a description of a typical flow of how the different endpoints are called. However, you might want to deviate from this order depending on your setup.
### Step 0: Use the Two Company Search API to find the company
By using the Two Company Search API, you ensure that the user places an order on behalf of the correct organization. It enables an improved user experience and lowers the friction.
**Using Canonical IDs (Recommended):** The Company Search API returns a `canonical_id` for each company. You can use this canonical_id when creating orders and order intents instead of providing full company details. This ensures data accuracy and simplifies integration.
Example:
```json
{
"buyer": {
"company": {
"company_canonical_id": "abc123def456"
},
"representative": { ... }
}
}
```
### Step 1: Check whether a buyer will be accepted for credit during checkout (Order intent)
Use `POST /v1/order_intent` to credit check your buyers during the checkout. Only enable Two as the payment option if the credit check is approved.
Collect the `tracking_id` from the response of the order intent in order to connect the order_intent with the actual order being placed by the buyer.
### Step 2: Create order
Create an order by building a request body containing all required elements and call the `POST /v1/order` endpoint.
1. Read the state and status of the order response.
2. Check if the status is `APPROVED`.
3. Check if the state is `UNVERIFIED`, and redirect the user to the `payment_url`.
After completing the verfication, the user is redirected back to your order confirmation page.
### Step 3: Confirm order
On the order confirmation page use the `POST /v1/order//confirm` endpoint to confirm that the user has arrived at the order confirmation page.
### Step 4: Handling orders
#### Cancel order
Use `POST /v1/order//cancel` to cancel a specific order.
#### Edit order
Use `PUT /v1/order/` with a specified request body to edit an order.
#### Fulfil order
Use `POST /v1/order//fulfilled` with a specified request body to fulfil all line items of an order.
Note: Include a request body in order to do a partial fulfillment.
#### Refund order
Use `POST /v1/order//refund` to refund a specific order.
Note: Include a request body in order to do a partial refund.
## Environments
### Testing
https://api.sandbox.two.inc
Note: Read about our sandbox environment specific behaviour.
### Production
https://api.two.inc'
servers:
- url: https://api.sandbox.two.inc
description: Testing
- url: https://api.two.inc
description: Production
security: []
tags:
# --- truncated at 32 KB (36 KB total) ---
# Full source: https://artifacts.apis.io/two/openapi/two-invoice-api-openapi.yml