Resources

POST
/api/v2/invoices
Create an invoice

Params

  • number

    Invoice number. Defaults to +1 of highest number currently in account.

  • date

    Date string in the format “yyyy-mm-dd”

  • client_id

    Id of existing client. “client_id” OR “client” is required.

  • days

    Number of days from “date” that invoice payment is due.

  • our_reference

    Name of person who acts as reference at senders company

  • your_reference

    Name of person who acts as reference at recievers company

  • locale

    One of: “sv”, “en”, “da”, “nb”

  • currency
  • settings Must be a Hash
  • settings[invoice_template]

    One of: “urban”, “clean”, “iconic”, “foxy”, “static”, “original”, “croatia”

  • settings[show_product_code]

    Boolean. Should the invoice show the product code column?

  • client Must be a Hash

    See documentation for 'create client' for detailed information about the client params. Note: it's not possible to update a client on a invoice update, only create a client on invoice create.


    Metadata: :only: :create
  • rows Must be an Array of nested elements
  • rows[id]
  • rows[product_id]
  • rows[discount]

    Discount in %

  • rows[amount]

    How many units of this item? May be fractional (“1.5”).

  • rows[text]

    Max length 255

  • rows[product_code]

    Max length 30

  • rows[product_name]

    Max length 255

  • rows[product_unit]

    Max length 30

  • rows[product_price]

    Price of this item. May be fractional (“9.95”).

  • rows[product_tax]

    One of 25, 12, 6, 0

  • rows[text_row]

    Boolean. Show this row as purely text?

  • rows[sort_order]

Examples

# Create an invoice to an existing client.
POST /api/v2/invoices
{
  "client_id": 1,
  "rows": [
    {
      "product_name": "My product",
      "product_tax": 25,
      "product_price": "100",
      "amount": "10"
    },
    {
      "product_name": "My product 2",
      "product_tax": 12,
      "product_price": "100",
      "amount": "10 st"
    },
    {
      "text": "Some arbitrary text",
      "text_row": true
    }
  ]
}
201
{
  "data": {
    "id": 1,
    "number": 1,
    "date": "2021-01-25",
    "client_id": 1,
    "days": 30,
    "our_reference": "",
    "your_reference": "",
    "sent": false,
    "paid_at": null,
    "locale": "sv",
    "currency": "SEK",
    "settings": {
      "invoice_template": "croatia",
      "prices_inc_tax": "no",
      "show_product_code": false
    },
    "sum": "2370.0",
    "net": "2000.0",
    "tax": "370.0",
    "tax_details": {
      "25": "250.0",
      "12": "120.0"
    },
    "address": {
      "name": "Google Inc",
      "street_address": "1600 Amphitheatre Parkway",
      "care_of": "",
      "zip_code": "940 43",
      "city": "Mountain View",
      "country": "SE"
    },
    "rows": [
      {
        "id": 1,
        "product_id": 0,
        "discount": 0,
        "amount": "10.0",
        "text": "",
        "product_code": null,
        "product_name": "My product",
        "product_unit": "",
        "product_price": "100.0",
        "product_tax": 25,
        "text_row": false,
        "sort_order": 0,
        "tax_deductible": false
      },
      {
        "id": 2,
        "product_id": 0,
        "discount": 0,
        "amount": "10.0",
        "text": "",
        "product_code": null,
        "product_name": "My product 2",
        "product_unit": "",
        "product_price": "100.0",
        "product_tax": 12,
        "text_row": false,
        "sort_order": 1,
        "tax_deductible": false
      },
      {
        "id": 3,
        "product_id": 0,
        "discount": 0,
        "amount": "0.0",
        "text": "Some arbitrary text",
        "product_code": null,
        "product_name": "",
        "product_unit": "",
        "product_price": "0.0",
        "product_tax": 0,
        "text_row": true,
        "sort_order": 2,
        "tax_deductible": false
      }
    ]
  }
}
# Invalid invoice
POST /api/v2/invoices
{
  "client_id": 0,
  "date": "",
  "rows": [
    {
      "product_code": "ABCD-ABCD-ABCD-ABCD-ABCD-ABCD-ABCD-"
    }
  ]
}
422
{
  "errors": {
    "client_id": [
      {
        "error": "blank"
      }
    ],
    "rows": [
      {
        "0": {
          "rows.product_code": [
            {
              "error": "too_long",
              "count": 30
            }
          ]
        }
      }
    ]
  }
}
# Create an invoice to a new client.
POST /api/v2/invoices
{
  "date": "2021-01-25",
  "client": {
    "company": "Google",
    "address": {
      "street_address": "1600 Amphitheatre Parkway",
      "zip_code": "94043",
      "city": "Mountain View",
      "country": "SE"
    }
  },
  "rows": [
    {
      "product_name": "My product",
      "product_tax": 25,
      "product_price": "100",
      "amount": "10"
    }
  ]
}
201
{
  "data": {
    "id": 4,
    "number": 1,
    "date": "2021-01-25",
    "client_id": 3,
    "days": 30,
    "our_reference": "",
    "your_reference": "",
    "sent": false,
    "paid_at": null,
    "locale": "sv",
    "currency": "SEK",
    "settings": {
      "invoice_template": "croatia",
      "prices_inc_tax": "no",
      "show_product_code": false
    },
    "sum": "1250.0",
    "net": "1000.0",
    "tax": "250.0",
    "tax_details": {
      "25": "250.0"
    },
    "address": {
      "name": "Google",
      "street_address": "1600 Amphitheatre Parkway",
      "care_of": "",
      "zip_code": "940 43",
      "city": "Mountain View",
      "country": "SE"
    },
    "rows": [
      {
        "id": 7,
        "product_id": 0,
        "discount": 0,
        "amount": "10.0",
        "text": "",
        "product_code": null,
        "product_name": "My product",
        "product_unit": "",
        "product_price": "100.0",
        "product_tax": 25,
        "text_row": false,
        "sort_order": 0,
        "tax_deductible": false
      }
    ]
  }
}