Two Billing Account API (1.0)

Download OpenAPI specification:Download

Overview and usage

This API is for creating and managing billing accounts and is currently available exclusively for UK-based merchants. A billing account serves as a record of transactions and payments for a collection of orders. It helps track and manage the payments a customer owes for the services or products they have received. Billing accounts can be linked to specific businesses and are used to generate grouped payment statements.

To request access to the billing account service, please contact our team at support@two.inc.

The API enables you to:

  • Create billing accounts for businesses, allowing them to receive grouped payment statements.
  • Define the schedule for sending out grouped payment statements from the billing account.
  • Specify the primary and secondary email recipients who will receive the grouped payment statement emails.

Below is a typical flow of how the API endpoints are used to create a new billing account.

Step 1: Create Billing Account

Use POST /billing/v1/account to create a new billing account for a given company by passing their legal name and number and defining the billing account configuration for the payment terms, schedule and any delay days. The request response will return a global id which represents the billing_account_id.

Step 2: Attach Order To Billing Account

When building the request body for creating an order POST /order you can specify the billing_account_id when creating an order. This will then attach the order to the specified billing account.

Key Details and Interactions for Billing Account Setup**

Schedule

  • The schedule you set determines how often the recipients on the billing account receive their grouped statements from Two. When setting the schedule, ensure it aligns with the payment terms so that recipients receive their statements within a time frame that makes sense relative to the due date. Avoid setting a schedule that is too frequent for long payment terms or too delayed for short order terms.

Due in Days

  • The due in days setting specifies the payment terms for all orders assigned to the billing account. The total repayment period is calculated based on the schedule and the "due in days" you set. For example, if you choose a schedule of DAILY and set due_in_days to 14, your buyer will have 14 days to pay their order from the time they receive their statement, which in this setup, starts the next day. A common configuration we support is "End of Month plus 30 days." To achieve this, set the schedule to MONTHLY and the due_in_days to 30. This setup will allow billing account recipients to receive their grouped statement at the end of the month, with payment terms starting from that date. As a rule, the payment term begins when the billing account recipients receive their statement.

Generation Delay Days

  • The primary purpose of setting delay days is to allow you, as the merchant, to process any final refunds or changes for orders on a billing account before recipients receive their statements. Note that the generation delay window does not include newly fulfilled orders in the same billing cycle. Any orders created within the generation delay window will roll over to the next billing cycle. By default, billing accounts are created with a 4-day generation delay, but you can adjust this during the setup process if you need a shorter or longer window.

Account Name

  • For a given company, you can create multiple billing accounts to accommodate different areas, departments, or branches. To ensure these accounts are easily distinguishable, we recommend assigning descriptive account names to differentiate them.

Environments

Create Billing Account

Create new billing account handler

The endpoint POST /billing/v1/account enables the merchant to create a new billing account for a specific buyer. A billing account is a record of financial transactions for goods or services that a customer or client has received and owes payment for. This endpoint allows you to configure the terms and configuration of the billing account through the request body. Key configurations include, the billing account schedule, due_in_days, currency, invoice_email , cc_email_addresses, primary_email_addresses, generation_delay_days and the buyer_company

SecurityX-Api-Key
Request
Request Body schema: application/json
primary_email_addresses
required
Array of strings <email> (Primary Email Addresses)

List of email addresses set to receive billing account emails

cc_email_addresses
Array of strings <email> (Cc Email Addresses)

List of CC email addresses set to receive billing account emails

schedule
required
string (BillingPeriod)

An enumeration for choosing the time period at which grouped invoices will be sent out. Note that BIWEEKLY means twice a month and NOT twice a week. Enum: DAILY WEEKLY BIWEEKLY MONTHLY.

Enum: "DAILY" "WEEKLY" "MONTHLY" "BIWEEKLY"
required
object (Buyer Company)

The company for which the billing account is being created

due_in_days
required
integer (Due In Days) [ 5 .. 60 ]

Due in days to allow for the monthly billing schedule, can be greater than or equal to 5 and less than or equal to 60

currency
required
string (CurrencyEnum)

Currency code in ISO 4217 format. E.g. 'NOK'

Enum: "NOK" "SEK" "GBP" "EUR" "USD" "DKK" "CHF" "RON"
generation_delay_days
integer (Generation Delay Days) >= 0
Default: 4

Number of days to delay the grouped invoice being sent out

account_name
string (Account Name)

A name to identify the billing account

phone_number
string (Phone Number)

Phone number that should be used to contact the account holder

Responses
201

Create billing account

default

Error response

post/billing/v1/account
Request samples
application/json
{
  • "primary_email_addresses": [
    ],
  • "cc_email_addresses": [
    ],
  • "schedule": "DAILY",
  • "buyer_company": {
    },
  • "due_in_days": 5,
  • "currency": "NOK",
  • "generation_delay_days": 4,
  • "account_name": "string",
  • "phone_number": "string"
}
Response samples
application/json
{
  • "primary_email_addresses": [
    ],
  • "cc_email_addresses": [
    ],
  • "schedule": "DAILY",
  • "buyer_company": {
    },
  • "due_in_days": 0,
  • "currency": "NOK",
  • "generation_delay_days": 4,
  • "account_name": "string",
  • "phone_number": "string",
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
}

Update Billing Account

Update billing account handler

Note: To update primary_email_addresses, cc_email_addresses, trade_names the request body must include all new values, including values that are not being updated. So if you are adding or removing even a single email to the emailing lists (primary_email_addresses & cc_email_addresses), the entire list must be provided with the updates you need to make.

SecurityX-Api-Key
Request
path Parameters
id
required
string

The ID of the billing account to be updated

Request Body schema: application/json
due_in_days
integer (Due In Days) [ 5 .. 60 ]

Due in days to allow for the monthly billing schedule, can be greater than or equal to 5 and less than or equal to 60

generation_delay_days
integer (Generation Delay Days) >= 0
Default: 4

Number of days to delay the grouped invoice being sent out

primary_email_addresses
Array of strings <email> (Primary Email Addresses)

List of email addresses set to receive billing account emails

cc_email_addresses
Array of strings <email> (Cc Email Addresses)

List of CC email addresses set to receive billing account emails

account_name
string (Account Name)

A name to identify the billing account

phone_number
string (Phone Number)

Phone number for contacting the account holder

Responses
200

Update billing account

404

The billing account with the given ID was not found

default

Error response

patch/billing/v1/account/{id}
Request samples
application/json
{
  • "due_in_days": 5,
  • "generation_delay_days": 4,
  • "primary_email_addresses": [
    ],
  • "cc_email_addresses": [
    ],
  • "account_name": "string",
  • "phone_number": "string"
}
Response samples
application/json
{
  • "primary_email_addresses": [
    ],
  • "cc_email_addresses": [
    ],
  • "schedule": "DAILY",
  • "buyer_company": {
    },
  • "due_in_days": 0,
  • "currency": "NOK",
  • "generation_delay_days": 4,
  • "account_name": "string",
  • "phone_number": "string",
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
}

Get Billing Account Details

Get billing account by ID.

The endpoint /billing/v1/account/{id} allows you to fetch the details for a given billing account that has been specified by its id

SecurityX-Api-Key
Request
path Parameters
id
required
string

The ID of the billing account to fetch

Responses
200

OK

404

The billing account with the given ID was not found

default

Error response

get/billing/v1/account/{id}
Request samples
Response samples
application/json
{
  • "primary_email_addresses": [
    ],
  • "cc_email_addresses": [
    ],
  • "schedule": "DAILY",
  • "buyer_company": {
    },
  • "due_in_days": 0,
  • "currency": "NOK",
  • "generation_delay_days": 4,
  • "account_name": "string",
  • "phone_number": "string",
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
}

Billing Statement

Generate previews for billing statements

returns the statement as a file. Can choose period_status by status parameter. This will default to OPEN. Args: account_id (UUID): Billing account ID

SecurityX-Api-Key
Request
path Parameters
account_id
required
string

Billing account ID

Responses
200

OK

404

The billing account with the given ID was not found

default

Error response

get/billing/v1/account/{account_id}/preview_download
Request samples
Response samples
application/json
{
  • "error_message": "string"
}

Get all grouped payment statements for authenticated merchant.

SecurityX-Api-Key
Request
query Parameters
billing_account_id
string <uuid> (Billing Account Id)
limit
integer (Limit) [ 1 .. 1000 ]
Default: 3000
page_cursor
string (Page Cursor)
search_filter
string (Search Filter)
due_date_from
string (Due Date From)
due_date_to
string (Due Date To)
payment_statuses
string (Payment Statuses)
downloaded
boolean (Downloaded)
Responses
200

The list with all grouped payment statements for authenticated merchant.

default

Error response

get/billing/v1/statement
Request samples
Response samples
application/json
{
  • "statements": [
    ],
  • "cursor_page_metadata": {
    }
}

Get the download URL for the statement document.

SecurityX-Api-Key
Request
path Parameters
statement_id
required
string
Responses
200

The download URL for the statement document.

404

Statement not found

default

Error response

get/billing/v1/statement/{statement_id}/download_url
Request samples
Response samples
application/json
{
  • "url": "string"
}

Get billing period summary

"Statements" object: Contains all statements issued by Two for this billing period, each statement object reflecting information displayed on the statements the moment they were issued. This section does not change unless a new statement is issued. "Totals" section: Shows the latest reconciliation status of the billing period, and gets updated real-time as each transaction (payments, refunds, etc.) related to invoices in the billing period are reconciled. It shows the current financial status of the billing period, including the currently outstanding balance, and the total payments, total refunds, etc. reconciled against these invoices. To get these details with more granularity, you should subscribe to our webhooks here. Args: billing_account_id (str): Billing account identifier period_id (str): Billing period identifier

SecurityX-Api-Key
Request
path Parameters
billing_account_id
required
string

Billing account identifier

period_id
required
string

Billing period identifier

Responses
200

Billing period summary

404

The billing period with the given attributes was not found

default

Error response

get/billing/v1/account/{billing_account_id}/period/{period_id}
Request samples
Response samples
application/json
{
  • "id": "string",
  • "billing_account_id": "string",
  • "start_date": "2019-08-24",
  • "end_date": "2019-08-24",
  • "currency": "NOK",
  • "totals": {
    },
  • "statements": [
    ],
  • "bank_account": {
    }
}