Aviate Billing Accounts

A billing account holds the commercial details of a customer that Aviate quotes, orders and contracts use: company and contact, address, currency and tax registrations. Each billing account is linked to a Kill Bill account, either an existing one or one that Aviate creates with the billing account. This section documents the APIs to create and manage billing accounts.

Before You Begin

Authentication

The Aviate Plugin uses a JWT based authentication mechanism. Thus, all the APIs listed in this document require a valid token. This can be obtained via the Auth API.

When Aviate permission checks are enforced (com.killbill.billing.plugin.aviate.auth.permissions.mode=enforce, off by default), each endpoint below requires the permissions listed in its section, and returns a status code of 403 when the caller's role does not have them. See Aviate Access Control for roles and permissions.

Tenancy

Each endpoint requires the standard Kill Bill X-Killbill-ApiKey and X-Killbill-ApiSecret headers, which identify the tenant. Billing accounts belong to a tenant, and their Kill Bill accounts must belong to the same tenant.

When Aviate creates a Kill Bill account, it uses the optional X-Killbill-CreatedBy header (admin by default) as the name of the user creating it.

Resources

This section lists the models used by the Aviate billing account APIs.

BillingAccount

The commercial details of a customer, linked to a Kill Bill account. A field that is not set is returned as an empty string.

Name Type Description
billingAccountId string (UUID) Unique identifier of the billing account, generated by Aviate
kbAccountId string (UUID) Kill Bill account of the billing account. Optional when creating: without it, Aviate creates the Kill Bill account. It cannot be changed afterwards
companyName string Company name
contactName string Name of the contact person
email string Email address of the contact
telephone string Telephone number of the contact
currency string Currency of the customer, as an ISO 4217 code (for example USD)
address Address Address of the customer
taxRegistrations list of TaxRegistration Tax registrations of the customer

Address

Name Type Description
addressLine1 string First address line
addressLine2 string Second address line
city string City
state string State, province or region
country string Country, as an ISO 3166-1 alpha-2 code (for example US)
postalCode string Postal code

TaxRegistration

A tax registration of the customer, for example a VAT or sales tax registration.

Name Type Description
taxRegistrationId string (UUID) Unique identifier of the tax registration, generated by Aviate
billingAccountId string (UUID) Billing account of the tax registration, set by Aviate
name string Name of the registration
exempt boolean Whether the customer is exempt from this tax
trn string Tax registration number
address Address Address registered for this tax

Billing Account APIs

Create a Billing Account

Creates a billing account. No field is required.

With a kbAccountId, the billing account is linked to that Kill Bill account, which must exist in the tenant. Without it, Aviate first creates a Kill Bill account with:

The company name, address and telephone are not copied to the Kill Bill account.

A Kill Bill account should have only one billing account: Get a Billing Account by Kill Bill Account expects exactly one.

HTTP Request

POST /plugins/aviate-plugin/v1/ba

Example Request:

curl -X POST \
     -H "Authorization: Bearer ${ID_TOKEN}" \
     -H 'X-Killbill-ApiKey: bob' \
     -H 'X-Killbill-ApiSecret: lazar' \
     -H 'X-Killbill-CreatedBy: demo' \
     -H 'Content-Type: application/json' \
     -d '{
           "companyName": "Acme Corp",
           "contactName": "Jane Doe",
           "email": "[email protected]",
           "telephone": "+1 415 555 0100",
           "currency": "USD",
           "address": {
             "addressLine1": "100 Market St",
             "addressLine2": "Suite 300",
             "city": "San Francisco",
             "state": "CA",
             "country": "US",
             "postalCode": "94105"
           },
           "taxRegistrations": [
             {
               "name": "California sales tax",
               "exempt": false,
               "trn": "CA-123-4567",
               "address": {
                 "addressLine1": "100 Market St",
                 "city": "San Francisco",
                 "state": "CA",
                 "country": "US",
                 "postalCode": "94105"
               }
             }
           ]
         }' \
     'http://127.0.0.1:8080/plugins/aviate-plugin/v1/ba'

Example Response:

{
  "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
  "kbAccountId": "bd3ae490-35d2-4627-b6e6-d9ac07f1a1f0",
  "companyName": "Acme Corp",
  "contactName": "Jane Doe",
  "email": "[email protected]",
  "address": {
    "addressLine1": "100 Market St",
    "addressLine2": "Suite 300",
    "city": "San Francisco",
    "state": "CA",
    "country": "US",
    "postalCode": "94105"
  },
  "telephone": "+1 415 555 0100",
  "currency": "USD",
  "taxRegistrations": [
    {
      "taxRegistrationId": "e3d1ef78-da5e-4748-aee3-65b354af8cc8",
      "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
      "name": "California sales tax",
      "exempt": false,
      "trn": "CA-123-4567",
      "address": {
        "addressLine1": "100 Market St",
        "addressLine2": "",
        "city": "San Francisco",
        "state": "CA",
        "country": "US",
        "postalCode": "94105"
      }
    }
  ]
}

Request Body

A BillingAccount object. The billingAccountId and the taxRegistrationId and billingAccountId of the tax registrations are generated by Aviate.

Query Parameters

None

Permissions

aviate_ba:create, and the Kill Bill permission account:create

Response

If successful, returns a status code of 201 and the created BillingAccount object. Otherwise:

Status Reason
400 The kbAccountId is not a valid UUID, or there is no Kill Bill account with this id in the tenant

List Billing Accounts

Lists the billing accounts of the tenant, oldest first.

HTTP Request

GET /plugins/aviate-plugin/v1/ba

Example Request:

curl -X GET \
     -H "Authorization: Bearer ${ID_TOKEN}" \
     -H 'X-Killbill-ApiKey: bob' \
     -H 'X-Killbill-ApiSecret: lazar' \
     'http://127.0.0.1:8080/plugins/aviate-plugin/v1/ba?offset=1&limit=1'

Example Response:

[
  {
    "billingAccountId": "f5a70977-5082-4f9e-a0b7-df48f1964596",
    "kbAccountId": "291c394d-51c3-49b2-994e-6db55b0ee831",
    "companyName": "Bluebird Ltd",
    "contactName": "Sam Taylor",
    "email": "[email protected]",
    "address": {
      "addressLine1": "",
      "addressLine2": "",
      "city": "London",
      "state": "",
      "country": "GB",
      "postalCode": ""
    },
    "telephone": "",
    "currency": "GBP",
    "taxRegistrations": []
  }
]

Query Parameters

Name Type Required Default Description
offset integer false 0 Number of billing accounts to skip
limit integer false 50 Maximum number of billing accounts to return. Values above 200 are reduced to 200

Permissions

aviate_ba:view

Response

If successful, returns a status code of 200 and a list of BillingAccount objects. Otherwise:

Status Reason
400 offset is negative, or limit is lower than 1

Search Billing Accounts

Finds the billing accounts of the tenant whose id or Kill Bill account id is the search string, or whose company name, contact name or email contains it (ignoring case).

HTTP Request

GET /plugins/aviate-plugin/v1/ba/search

Example Request:

curl -X GET \
     -H "Authorization: Bearer ${ID_TOKEN}" \
     -H 'X-Killbill-ApiKey: bob' \
     -H 'X-Killbill-ApiSecret: lazar' \
     'http://127.0.0.1:8080/plugins/aviate-plugin/v1/ba/search?q=acme'

Example Response:

[
  {
    "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
    "kbAccountId": "bd3ae490-35d2-4627-b6e6-d9ac07f1a1f0",
    "companyName": "Acme Corp",
    "contactName": "Jane Doe",
    "email": "[email protected]",
    "address": {
      "addressLine1": "100 Market St",
      "addressLine2": "Suite 300",
      "city": "San Francisco",
      "state": "CA",
      "country": "US",
      "postalCode": "94105"
    },
    "telephone": "+1 415 555 0100",
    "currency": "USD",
    "taxRegistrations": [
      {
        "taxRegistrationId": "e3d1ef78-da5e-4748-aee3-65b354af8cc8",
        "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
        "name": "California sales tax",
        "exempt": false,
        "trn": "CA-123-4567",
        "address": {
          "addressLine1": "100 Market St",
          "addressLine2": "",
          "city": "San Francisco",
          "state": "CA",
          "country": "US",
          "postalCode": "94105"
        }
      }
    ]
  }
]

Query Parameters

Name Type Required Default Description
q string true none Search string, at least 3 characters

Permissions

aviate_ba:view

Response

If successful, returns a status code of 200 and a list of BillingAccount objects, empty when nothing matches. Otherwise:

Status Reason
400 The search string has fewer than 3 characters
422 More than 100 billing accounts match: narrow the search

Get a Billing Account

Retrieves a billing account by its id.

HTTP Request

GET /plugins/aviate-plugin/v1/ba/{billingAccountId}

Example Request:

curl -X GET \
     -H "Authorization: Bearer ${ID_TOKEN}" \
     -H 'X-Killbill-ApiKey: bob' \
     -H 'X-Killbill-ApiSecret: lazar' \
     'http://127.0.0.1:8080/plugins/aviate-plugin/v1/ba/f1a2e8a6-3151-4e6b-9011-dc183d6a6f91'

Example Response:

{
  "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
  "kbAccountId": "bd3ae490-35d2-4627-b6e6-d9ac07f1a1f0",
  "companyName": "Acme Corp",
  "contactName": "Jane Doe",
  "email": "[email protected]",
  "address": {
    "addressLine1": "100 Market St",
    "addressLine2": "Suite 300",
    "city": "San Francisco",
    "state": "CA",
    "country": "US",
    "postalCode": "94105"
  },
  "telephone": "+1 415 555 0100",
  "currency": "USD",
  "taxRegistrations": [
    {
      "taxRegistrationId": "e3d1ef78-da5e-4748-aee3-65b354af8cc8",
      "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
      "name": "California sales tax",
      "exempt": false,
      "trn": "CA-123-4567",
      "address": {
        "addressLine1": "100 Market St",
        "addressLine2": "",
        "city": "San Francisco",
        "state": "CA",
        "country": "US",
        "postalCode": "94105"
      }
    }
  ]
}

Query Parameters

None

Permissions

aviate_ba:view

Response

If successful, returns a status code of 200 and a BillingAccount object. Returns 404 if the billing account does not exist.

Get a Billing Account by Kill Bill Account

Retrieves the billing account linked to a Kill Bill account.

HTTP Request

GET /plugins/aviate-plugin/v1/ba/forKbAccountId/{kbAccountId}

Example Request:

curl -X GET \
     -H "Authorization: Bearer ${ID_TOKEN}" \
     -H 'X-Killbill-ApiKey: bob' \
     -H 'X-Killbill-ApiSecret: lazar' \
     'http://127.0.0.1:8080/plugins/aviate-plugin/v1/ba/forKbAccountId/bd3ae490-35d2-4627-b6e6-d9ac07f1a1f0'

Example Response:

{
  "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
  "kbAccountId": "bd3ae490-35d2-4627-b6e6-d9ac07f1a1f0",
  "companyName": "Acme Corp",
  "contactName": "Jane Doe",
  "email": "[email protected]",
  "address": {
    "addressLine1": "100 Market St",
    "addressLine2": "Suite 300",
    "city": "San Francisco",
    "state": "CA",
    "country": "US",
    "postalCode": "94105"
  },
  "telephone": "+1 415 555 0100",
  "currency": "USD",
  "taxRegistrations": [
    {
      "taxRegistrationId": "e3d1ef78-da5e-4748-aee3-65b354af8cc8",
      "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
      "name": "California sales tax",
      "exempt": false,
      "trn": "CA-123-4567",
      "address": {
        "addressLine1": "100 Market St",
        "addressLine2": "",
        "city": "San Francisco",
        "state": "CA",
        "country": "US",
        "postalCode": "94105"
      }
    }
  ]
}

Query Parameters

None

Permissions

aviate_ba:view

Response

If successful, returns a status code of 200 and a BillingAccount object.

Update a Billing Account

Updates a billing account. The request body replaces all the fields of the billing account: a field that is left out is set to empty, so send the complete billing account (for example as returned by Get a Billing Account) with your changes.

The kbAccountId cannot be changed: when it is in the request body, it must be the current one. The tax registrations are kept unless replaceTaxRegistrations is true: they are then replaced by the ones in the request body, which keep their taxRegistrationId when it is given.

The Kill Bill account is not updated.

HTTP Request

PUT /plugins/aviate-plugin/v1/ba/{billingAccountId}

Example Request:

curl -X PUT \
     -H "Authorization: Bearer ${ID_TOKEN}" \
     -H 'X-Killbill-ApiKey: bob' \
     -H 'X-Killbill-ApiSecret: lazar' \
     -H 'Content-Type: application/json' \
     -d '{
           "companyName": "Acme Corporation",
           "contactName": "Jane Doe",
           "email": "[email protected]",
           "telephone": "+1 415 555 0100",
           "currency": "USD",
           "address": {
             "addressLine1": "100 Market St",
             "addressLine2": "Suite 300",
             "city": "San Francisco",
             "state": "CA",
             "country": "US",
             "postalCode": "94105"
           },
           "taxRegistrations": [
             {
               "name": "California sales tax (2027)",
               "exempt": false,
               "trn": "CA-123-4567",
               "address": {
                 "addressLine1": "100 Market St",
                 "city": "San Francisco",
                 "state": "CA",
                 "country": "US",
                 "postalCode": "94105"
               }
             }
           ]
         }' \
     'http://127.0.0.1:8080/plugins/aviate-plugin/v1/ba/f1a2e8a6-3151-4e6b-9011-dc183d6a6f91?replaceTaxRegistrations=true'

Example Response:

{
  "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
  "kbAccountId": "bd3ae490-35d2-4627-b6e6-d9ac07f1a1f0",
  "companyName": "Acme Corporation",
  "contactName": "Jane Doe",
  "email": "[email protected]",
  "address": {
    "addressLine1": "100 Market St",
    "addressLine2": "Suite 300",
    "city": "San Francisco",
    "state": "CA",
    "country": "US",
    "postalCode": "94105"
  },
  "telephone": "+1 415 555 0100",
  "currency": "USD",
  "taxRegistrations": [
    {
      "taxRegistrationId": "2cc691bf-42dd-4f92-83e6-12017079a0ba",
      "billingAccountId": "f1a2e8a6-3151-4e6b-9011-dc183d6a6f91",
      "name": "California sales tax (2027)",
      "exempt": false,
      "trn": "CA-123-4567",
      "address": {
        "addressLine1": "100 Market St",
        "addressLine2": "",
        "city": "San Francisco",
        "state": "CA",
        "country": "US",
        "postalCode": "94105"
      }
    }
  ]
}

Request Body

A BillingAccount object, with all its fields.

Query Parameters

Name Type Required Default Description
replaceTaxRegistrations boolean false false If true, replaces the tax registrations with the ones in the request body

Permissions

aviate_ba:update

Response

If successful, returns a status code of 200 and the updated BillingAccount object. Otherwise:

Status Reason
400 The kbAccountId in the request body is not the current one
404 The billing account does not exist

Delete a Billing Account

Deletes a billing account and its tax registrations. The Kill Bill account is not deleted.

A billing account used by a quote, an order or a contract is only deleted with force=true; these quotes, orders and contracts are not changed.

HTTP Request

DELETE /plugins/aviate-plugin/v1/ba/{billingAccountId}

Example Request:

curl -X DELETE \
     -H "Authorization: Bearer ${ID_TOKEN}" \
     -H 'X-Killbill-ApiKey: bob' \
     -H 'X-Killbill-ApiSecret: lazar' \
     'http://127.0.0.1:8080/plugins/aviate-plugin/v1/ba/f1a2e8a6-3151-4e6b-9011-dc183d6a6f91'

Example Response:

HTTP/1.1 204 No Content

Query Parameters

Name Type Required Default Description
force boolean false false If true, deletes the billing account even when a quote, an order or a contract uses it

Permissions

aviate_ba:delete

Response

If successful, returns a status code of 204 and an empty body. Otherwise:

Status Reason
404 The billing account does not exist
409 A quote, an order or a contract uses the billing account, and force is not true