Skip to content

3PL Billing

If you are a 3PL you might want to handle your client billing through the API, for example, if you want to integrate with your current accounting procedure.

There are 11 actions you can use to work with bills and billing profiles:

  1. Create a Bill
  2. Recalculate a Bill
  3. Update a Bill’s status
  4. Submit a Bill to your client
  5. Delete a Bill
  6. Add an Ad-Hoc Charge
  7. Update an Ad-Hoc Charge
  8. Read Ad-Hoc Charges
  9. List Billing Profiles
  10. List Bills
  11. Export a Bill

Create a Bill

This is the first action you want to take when billing a customer, in this case, you will need to call the bill_create mutation as follows:

mutation{
  bill_create(data:{
    customer_account_id:"7556"
    start_date:"2021-11-01"
    end_date:"2021-11-04"
    }
  )
  {
    request_id
    complexity
    bill{
      id
      legacy_id
      status
      customer_name
      profile_name
      created_at
      due_date
      amount
      totals(first: 5){
        edges{
          node{
            id
            legacy_id
            amount
            label
            category
            quantity
          }
        }
      }
      bill_exports(first: 5){
        edges{
          node{
            id
            legacy_id
            status
            file_url 
          }
        }
      }
      billing_period{
        start
        end
      }
      billing_frequency
    }
  }
}

And this is an example response you should be getting:

{
  "data": {
    "bill_create": {
      "request_id": "618410c9dac8be5f60d8098a",
      "complexity": 1,
      "bill": {
        "id": "QmlsbDo1ODkxNQ==",
        "legacy_id": 58915,
        "status": "queued",
        "customer_name": "Child Account Nr2",
        "profile_name": "Test",
        "created_at": "2021-11-04T16:56:41",
        "due_date": null,
        "amount": "0.00",
        "totals": {
          "edges": [
            {
              "node": {
                "id": "RmVlQ2F0ZWdvcnlUb3RhbDoxNzg2NzQ=",
                "legacy_id": 178674,
                "amount": "0.00",
                "label": null,
                "category": "recurring",
                "quantity": 0
              }
            },
            {
              "node": {
                "id": "RmVlQ2F0ZWdvcnlUb3RhbDoxNzg2NzU=",
                "legacy_id": 178675,
                "amount": "0.00",
                "label": null,
                "category": "order",
                "quantity": 0
              }
            }
          ]
        },
        "bill_exports": {
          "edges": []
        },
        "billing_period": {
          "start": "2021-11-01",
          "end": "2021-11-04"
        },
        "billing_frequency": "monthly"
      }
    }
  }
}

Note

This will only calculate the amount due in the provided time frame, billing profile and parameters must be previously set up in https://3pl.shiphero.com/threepl/

Recalculate a Bill

This can be used, for example, if there was an update to the profile assigned to the customer that affects the amount due. To find the draft bills that need it, see Find out-of-date draft bills. The mutation, in this case, is bill_recalculate:

mutation{
  bill_recalculate(data:{
    	customer_account_id:"7556"
    	id:"58915"
  	}
  )
  {
    request_id
    complexity
    bill{
      id
      legacy_id
      status
      customer_name
      profile_name
      created_at
      due_date
      amount
      totals(first: 5){
        edges{
          node{
            id
            legacy_id
            amount
            label
            category
            quantity
          }
        }
      }
      bill_exports(first: 5){
        edges{
          node{
            id
            legacy_id
            status
            file_url 
          }
        }
      }
      billing_period{
        start
        end
      }
      billing_frequency
    }
  }
}

You will receive a response similar to the following:

{
  "data": {
    "bill_recalculate": {
      "request_id": "618427a5f92531de6da4252d",
      "complexity": 1,
      "bill": {
        "id": "QmlsbDo1ODkxOA==",
        "legacy_id": 58918,
        "status": "queued",
        "customer_name": "Child Account Nr2",
        "profile_name": "Test",
        "created_at": "2021-11-04T18:34:13",
        "due_date": null,
        "amount": "0.00",
        "totals": {
          "edges": [
            {
              "node": {
                "id": "RmVlQ2F0ZWdvcnlUb3RhbDoxNzg2ODc=",
                "legacy_id": 178687,
                "amount": "0.00",
                "label": null,
                "category": "recurring",
                "quantity": 0
              }
            },
            {
              "node": {
                "id": "RmVlQ2F0ZWdvcnlUb3RhbDoxNzg2ODg=",
                "legacy_id": 178688,
                "amount": "0.00",
                "label": null,
                "category": "order",
                "quantity": 0
              }
            }
          ]
        },
        "bill_exports": {
          "edges": []
        },
        "billing_period": {
          "start": "2021-11-01",
          "end": "2021-11-04"
        },
        "billing_frequency": "monthly"
      }
    }
  }
}

Note

This mutation will delete the previously created bill and generate a new one using the same time frame, which will have a new ID. You can check this ID on the response.

Update a Bill’s status

This is used to change the bill’s status to draft, finalized, or paid. Draft is the default status, which allows you to audit and update as needed. Finalized sets the bill ready to be submitted to the client. Paid is used when the amount due was paid for by the client. Status is updated using the bill_update mutation:

mutation{
  bill_update(data:{
    	customer_account_id:"7556"
    	id:"58918"
    	status:"draft"
  	}
  )
  {
    request_id
    complexity
  }
}

As a response you will receive the request ID and the amount of credits expended.

Note

You can go back and forth between draft and finalized statuses in case you need to recalculate, but Paid can only be used on finalized bills, and once in this status, it can’t go back to draft or finalized.

bill_update only finds bills that belong to the authenticated account. If the id matches no bill, or matches a bill owned by another account, it returns Bill not found with code 9, whatever that bill’s status is. Status checks run only after the bill is found, so the transition rules above apply to your own bills as before. An id that matched no bill used to return Unexpected Error with code 22. See Billing errors.

Submit a Bill to your client

This mutation triggers an email to your client with the bill attached and adds the due date on your dashboard based on the payment terms you have configured for each customer. To do this use the bill_submit mutation:

mutation{
  bill_submit(data:{
    	customer_account_id:"7556"
    	id:"58918"    	
  	}
  )
  {
    request_id
    complexity
  }
}

As a response you will receive the request ID and the amount of credits expended.

Delete a Bill

This will delete the bill even if it was already submitted. The mutation for this action is bill_delete

mutation{
  bill_delete(data:{
    	customer_account_id:"7556"
    	id:"58918"
  	}
  )
  {
    request_id
    complexity
  }
}

As a response you will receive the request ID and the amount of credits expended.

Note

Once deleted, you can still see the bill on your dashboard, but you can’t undo this action.

Add an Ad-Hoc Charge

This can be used to add a one-off charge to a customer’s billing. You can optionally attach it to an existing bill using the bill_id field. The mutation for this action is bill_add_ad_hoc_charge:

mutation {
  bill_add_ad_hoc_charge(
    data: {
      customer_account_id: "7556"
      name: "Special Handling"
      description: "Custom packaging for fragile items"
      occurred_at: "2025-03-15"
      labor_unit_id: "TGFib3JVbml0OjEyMw=="
      unit_amount: "5"
      rate: "12.50"
    }
  ) {
    request_id
    complexity
    charge {
      id
      legacy_id
      name
      description
      occurred_at
      labor_unit_id
      unit_amount
      rate
    }
  }
}

Update an Ad-Hoc Charge

If you need to modify an existing ad-hoc charge, use the bill_update_ad_hoc_charge mutation:

mutation UpdateBillAdHocCharge($data: UpdateBillAdHocChargeInput!) {
  bill_update_ad_hoc_charge(data: $data) {
    request_id
    complexity
    charge {
      id
      legacy_id
      name
      description
      occurred_at
      labor_unit_id
      unit_amount
      rate
      bill_id
    }
  }
}

Note

Only custom charges can be updated. A charge created from an ad hoc rate on a billing profile returns Invalid charge id.

Read Ad-Hoc Charges

Use the ad_hoc_charges query to list the ad-hoc charges of your customers, or to fetch specific charges by ID. It returns custom charges, like the ones created with bill_add_ad_hoc_charge, and charges created from an ad hoc rate on a billing profile.

The query is available to 3PL accounts only. A customer account gets an empty list.

Note

This query requires the view:billing scope, and the user needs the billing.manage.read permission. The scope alone is not enough. A 3PL user restricted to a list of customers only gets the charges of those customers.

This example lists the charges of one customer in a date range, newest first:

query {
  ad_hoc_charges(
    customer_account_id: "QWNjb3VudDoxMjM0"
    date_from: "2026-07-01"
    date_to: "2026-07-31"
  ) {
    request_id
    complexity
    data(first: 50) {
      pageInfo {
        hasNextPage
        endCursor
      }
      edges {
        node {
          id
          name
          description
          occurred_at
          labor_unit_id
          unit_amount
          rate
          amount
          customer_account_id
          bill_id
        }
      }
    }
  }
}

And this is an example response:

{
  "data": {
    "ad_hoc_charges": {
      "request_id": "692ef1c2a4b3d87e5f109c3a",
      "complexity": 51,
      "data": {
        "pageInfo": {
          "hasNextPage": false,
          "endCursor": "YXJyYXljb25uZWN0aW9uOjA="
        },
        "edges": [
          {
            "node": {
              "id": "QWRIb2NDaGFyZ2U6MTIzNA==",
              "name": "Relabeling",
              "description": "Customer requested expedited handling.",
              "occurred_at": "2026-07-09T15:30:00Z",
              "labor_unit_id": "TGFib3JVbml0OjEyMzQ=",
              "unit_amount": "2.5",
              "rate": "19.99",
              "amount": "49.975",
              "customer_account_id": "QWNjb3VudDoxMjM0",
              "bill_id": null
            }
          }
        ]
      }
    }
  }
}

A few things to know about the fields:

  • name is the name of the charge. A charge created from a billing profile takes the name of its ad hoc rate.
  • unit_amount is the quantity of labor units charged, and rate is the rate per labor unit the charge was calculated with. A later edit of the billing profile does not change rate.
  • amount is the total of the charge: unit_amount times rate, rounded to four decimals. It is null when the charge has no rate.
  • customer_account_id is the account ID of the customer the charge is for.
  • bill_id is the ID of the bill the charge is on. It is null while the charge is not on a bill.
  • occurred_at is returned in UTC.

Filters

ArgumentTypeDescription
ids[String]Fetch these charges by ID. No other filter is needed.
bill_idStringCharges on this bill.
customer_account_idStringCharges for this customer.
date_fromDateInclusive start of the occurred_at range, for example "2026-07-01".
date_toDateInclusive end of the occurred_at range, for example "2026-07-31".

All the arguments are optional, but the query needs something to narrow the list:

  • Without ids, send at least one of bill_id, customer_account_id, date_from or date_to. Otherwise the query returns Listing ad hoc charges requires ids or at least one filter: bill_id, customer_account_id, or a date range (date_from and/or date_to).
  • date_from or date_to alone is a valid filter, and the range has no maximum length.
  • A date_from later than date_to returns date_from cannot be after date_to.
  • A null bill_id or customer_account_id is the same as leaving it out.
  • An ID that belongs to another account matches nothing. It does not return an error.

Charges on a bill

Pass bill_id to get every charge on a bill. This example sorts them by name:

query {
  ad_hoc_charges(bill_id: "QmlsbDoxMjM0") {
    request_id
    complexity
    data(first: 100, sort: "name") {
      edges {
        node {
          id
          name
          unit_amount
          rate
          amount
        }
      }
    }
  }
}

A charge that still points to a deleted bill is not returned, including when you fetch it by ID.

Fetch charges by ID

Pass ids to fetch specific charges. No other filter is needed:

query {
  ad_hoc_charges(
    ids: ["QWRIb2NDaGFyZ2U6MTIzNA==", "QWRIb2NDaGFyZ2U6MTIzNQ=="]
  ) {
    request_id
    complexity
    data(first: 10) {
      edges {
        node {
          id
          name
          amount
          bill_id
        }
      }
    }
  }
}

Sorting and pagination

  • sort accepts occurred_at, name or bill_id. Prefix the field with - for descending order. The default is newest first, by occurred_at. Any other field returns Invalid sort field '<field>'.
  • Pagination uses the standard first / after and last / before arguments, with up to 100 charges per page.

List Billing Profiles

Use the billing_profiles query to list your billing profiles, the customers assigned to each one, and how many rates each profile has per category.

The query is read-only and available to 3PL accounts only. A customer account gets an empty list.

Note

This query requires the view:billing scope, and the user needs the billing.manage.read permission. Reading customers.name also requires the view:pii scope.

This example lists billing profiles, most recently changed first:

query {
  billing_profiles {
    request_id
    complexity
    data(first: 25, sort: "-last_changed_at") {
      pageInfo {
        hasNextPage
        endCursor
      }
      edges {
        node {
          id
          name
          archived
          last_changed_at
          customers {
            account_id
            name
          }
          rate_counts {
            category
            total
            active
          }
        }
      }
    }
  }
}

And this is an example response:

{
  "data": {
    "billing_profiles": {
      "request_id": "692ef1c2a4b3d87e5f109c3a",
      "complexity": 26,
      "data": {
        "pageInfo": {
          "hasNextPage": false,
          "endCursor": "YXJyYXljb25uZWN0aW9uOjA="
        },
        "edges": [
          {
            "node": {
              "id": "QmlsbGluZ1Byb2ZpbGU6MTIzNA==",
              "name": "Standard rates",
              "archived": false,
              "last_changed_at": "2026-07-09T15:30:00",
              "customers": [
                {
                  "account_id": "QWNjb3VudDoxMjM0",
                  "name": "Acme Corp"
                }
              ],
              "rate_counts": [
                {
                  "category": "order",
                  "total": 6,
                  "active": 6
                },
                {
                  "category": "storage",
                  "total": 4,
                  "active": 3
                }
              ]
            }
          }
        ]
      }
    }
  }
}

A few things to know about the fields:

  • id is the same ID that Bill.billing_profile_id returns, so you can match a bill to its billing profile.
  • last_changed_at is the date of the last rate change or customer assignment on the profile, in UTC, or its creation date if it never changed. Removing a customer from a profile does not change this date.
  • rate_counts has one entry per category: ad_hoc, order, purchase_order, recurring, returns or storage. total is the number of rates of that category on the profile, and active is how many of them are active.

Filter by customer

Pass customer_account_id to get every billing profile a customer is assigned to. Archived billing profiles are left out unless you set include_archived to true:

query {
  billing_profiles(
    customer_account_id: "QWNjb3VudDoxMjM0"
    include_archived: true
  ) {
    request_id
    complexity
    data(first: 25) {
      edges {
        node {
          id
          name
          archived
          last_changed_at
        }
      }
    }
  }
}

A customer that does not belong to your account returns an empty list, not an error.

Search by name

Pass name to match part of the billing profile name. The search is case-insensitive:

query {
  billing_profiles(name: "standard") {
    request_id
    complexity
    data(first: 25) {
      edges {
        node {
          id
          name
        }
      }
    }
  }
}

Sorting and pagination

  • sort accepts name or last_changed_at. Prefix the field with - for descending order. The default is name, A to Z. Any other field returns Cannot sort by <field>.
  • Pagination uses the standard first / after and last / before arguments, with up to 100 billing profiles per page. first and last cannot be sent together.

Note

Reading a single billing profile with all its rates is not available yet.

List Bills

Use the bills query to list your bills, and the bill query to fetch one by ID. You can filter the list by a created_at range with from_date and to_date, by status, by customer with customer_account_id, and by out_of_date.

Note

Reading data on bills requires the view:billing scope. Reading customer_name also requires the view:pii scope.

This example lists the draft bills of one customer that need to be recalculated:

query {
  bills(
    customer_account_id: "QWNjb3VudDoxMjM0"
    status: "draft"
    out_of_date: true
  ) {
    request_id
    complexity
    data(first: 25) {
      pageInfo {
        hasNextPage
        endCursor
      }
      edges {
        node {
          id
          status
          customer_name
          profile_name
          created_at
          amount
          out_of_date
        }
      }
    }
  }
}

And this is an example response:

{
  "data": {
    "bills": {
      "request_id": "692ef1c2a4b3d87e5f109c3a",
      "complexity": 26,
      "data": {
        "pageInfo": {
          "hasNextPage": false,
          "endCursor": "YXJyYXljb25uZWN0aW9uOjA="
        },
        "edges": [
          {
            "node": {
              "id": "QmlsbDoxMjM0",
              "status": "draft",
              "customer_name": "Acme Corp",
              "profile_name": "Standard rates",
              "created_at": "2026-07-01T10:00:00",
              "amount": "1250.00",
              "out_of_date": true
            }
          }
        ]
      }
    }
  }
}

Filters

ArgumentTypeDescription
from_dateISODateTimeInclusive start of the created_at range.
to_dateISODateTimeInclusive end of the created_at range.
statusStringBills in this status, for example "draft" or "finalized".
customer_account_idStringBills issued to this customer, for example "QWNjb3VudDoxMjM0".
out_of_dateBooleantrue for the draft bills that need to be recalculated, false for every other bill you issued.
  • customer_account_id takes the customer’s Public API account ID. It only narrows the bills you can already see: a customer that does not belong to your account returns an empty list, not an error. A null value is the same as leaving it out.
  • out_of_date only applies to bills your account issued. A customer account that sends it gets an empty list.

Find out-of-date draft bills

out_of_date tells you whether a draft bill needs to be recalculated with bill_recalculate. It is available on both bill and bills.

A draft bill is out of date when, after the bill was created:

  • the billing profile assigned to the customer had a rate change, or
  • the customer was assigned to or removed from that billing profile.

A draft bill is also out of date when the customer has no billing profile, or when the relationship with the customer is not accepted by both accounts.

The value depends on who reads it:

  • For bills your account issued, it is true or false. Bills that are not drafts always return false.
  • For any other bill, for example when a customer reads a bill shared with them, it is null.

Export a Bill

Use the bill_export_create mutation to request the export files of a bill, the same files you can download from the bill on the website. The files are generated in the background, so the mutation returns the exports right away, usually before they are ready.

Note

This mutation requires the view:billing scope, and the user needs the billing update permission. It costs 5 credits.

Send the bill’s id in bill_id and the files you want in file_types: CATEGORY_SUMMARY for the category summary, COST_SUMMARY for the cost summary and CHARGES_LIST for the charges list. file_types takes 1 to 3 entries. A file type you repeat is requested once, so each file type returns one export.

mutation {
  bill_export_create(
    data: {
      bill_id: "QmlsbDoxMjM0"
      file_types: [CATEGORY_SUMMARY, COST_SUMMARY, CHARGES_LIST]
    }
  ) {
    request_id
    complexity
    bill_exports {
      id
      legacy_id
      file_type
      status
      created_at
      file_url
    }
  }
}

And this is an example response. It returns one export per file type, in the order you requested them:

{
  "data": {
    "bill_export_create": {
      "request_id": "6930a1f2c4b3d87e5f10a2b1",
      "complexity": 5,
      "bill_exports": [
        {
          "id": "QmlsbEV4cG9ydHM6NTY3OA==",
          "legacy_id": 5678,
          "file_type": "CATEGORY_SUMMARY",
          "status": "queued",
          "created_at": "2026-12-03T14:20:05",
          "file_url": null
        },
        {
          "id": "QmlsbEV4cG9ydHM6NTY3OQ==",
          "legacy_id": 5679,
          "file_type": "COST_SUMMARY",
          "status": "queued",
          "created_at": "2026-12-03T14:20:05",
          "file_url": null
        },
        {
          "id": "QmlsbEV4cG9ydHM6NTY4MA==",
          "legacy_id": 5680,
          "file_type": "CHARGES_LIST",
          "status": "queued",
          "created_at": "2026-12-03T14:20:06",
          "file_url": null
        }
      ]
    }
  }
}

Which bills you can export

  • Only the account that owns the bill, the 3PL that issued it, can request its exports. A bill that doesn’t exist, belongs to another account or is shared with your account as a customer returns Bill not found.
  • A bill that is still calculating, in tallying or queued status, cannot be exported yet. Wait until it is done, for example by reading its status with the bill query.
  • Bills in draft, finalized, paid and deleted status can be exported, the same as on the website.

Exports already in progress

If an export of a file type is already queued or exporting for the bill, the mutation returns that export instead of starting a new one, whoever started it: you, another user, the website or an automatic export.

The exception is a charges list requested by your customer. Its file is built for the customer, so it is not returned to you. While it is in progress, requesting CHARGES_LIST fails with A charges list export of bill <id> requested by the customer is in progress; try again when it is completed.

Each file type is started on its own. If the request fails while starting a later file type, the earlier ones stay started. Repeating the same request returns them while they are in progress, so it does not start them twice.

Get the files

When an export is completed, its status is completed and file_url has the URL to download the file. Until then, file_url is null. Read the bill’s bill_exports with the bill or bills query until the export you requested is completed, matching it by id:

query {
  bill(id: "QmlsbDoxMjM0") {
    request_id
    complexity
    data {
      id
      bill_exports(first: 10) {
        edges {
          node {
            id
            file_type
            status
            created_at
            file_url
          }
        }
      }
    }
  }
}
  • status is queued, exporting or completed. A summary export can go from queued to completed without going through exporting.
  • file_type is the file the export produces. It is null for older exports that did not record a file type.
  • created_at is when the export was requested.

A charges list export also emails the user who requested it when the file is ready, as it does on the website.