Quick-start guide

1. Create an Account on Space Invoices

It's also recommended to log as your access token will be automatically populated in all documentation examples.

If you haven't already, sign up for an account at spaceinvoices.com, as you'll need it to start making API calls.

2. Create an Organization

Organizations serve as the core unit for all other resources within the API, and are essential for issuing invoices.

Space Invoices embraces multi-tenant management, allowing a single account to have multiple organizations linked to it. Each organization represents a distinct legal entity, such as a business, NGO, club, or similar. Leverage this multi-tenancy feature to issue invoices on behalf of various businesses with ease.

If you haven't already, create an organization by sending the following request. You'll receive a JSON response containing the newly created organization's details, including the id. Take note of the id, as you'll need it for creating invoices in the next step.


Read the full Organization documentation >

      
        const response = await fetch('https://api.spaceinvoices.com/v1/Accounts/{id}/Organizations', {
  method: 'POST',
  headers: {
    "Authorization": "ACCESS_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "name": "International Space Agency",
    "address": "Rocket street 1",
    "city": "Brussels",
    "zip": "10000",
    "country": "Belgium"
  })
});      
    

Your access token is displayed in examples.

Prerequisite: npm install node-fetch

        
          curl -X POST 'https://api.spaceinvoices.com/v1/Accounts/{id}/Organizations' \
  -H 'Authorization: ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "International Space Agency",
    "address": "Rocket street 1",
    "city": "Brussels",
    "zip": "10000",
    "country": "Belgium"
  }'        
      

Your access token displayed in examples.

        
          import requests
url = "https://api.spaceinvoices.com/v1/Accounts/{id}/Organizations"
headers = {
  'Authorization': 'ACCESS_TOKEN',
  'Content-Type': 'application/json'
}
payload = {
  'name': 'International Space Agency',
  'address': 'Rocket street 1',
  'city': 'Brussels',
  'zip': '10000',
  'country': 'Belgium'
}
response = requests.post(url, json=payload, headers=headers)        
      

Your access token displayed in examples.

Response:

    
      {
  "id": "644c214c6ee48100249d5d7d",
  "name": "International Space Agency",
  "address": "Rocket street 1",
  "city": "Brussels",
  "zip": "10000",
  "country": "Belgium",
  "countryAlpha2Code": "BE",
  "locale": "nl-BE",
  "active": true,
  "activatedAt": "2023-04-28T19:41:00.914Z",
  "createdAt": "2023-04-28T19:41:00.930Z",
  "updatedAt": "2023-04-28T19:41:00.930Z",
  "custom": {},
  "_data": []
}    
  

Create and Send an Invoice

Creating an invoice is as simple as writing a few lines of code, requiring only the most basic data by default. The API automatically fills in the remaining details based on the organization's settings and customizations.

In this example the invoice is also marked as paid and sent to the client's email using convenience properties send and payments, more details below.


Organization {id}
Replace the '{id}' in the URL with your created organization's ID.

"payments"
The payments property contains payment information that will be added to the invoice, marking it as paid by a card. If the amount field is not specified, the full invoice amount will be used. If you wish to create an invoice that has not been paid yet, simply remove this property. For more details about adding payments, see the Payments section.

"send"
By including the send parameter, the invoice will also be sent automatically to the client's email using the default email message body set for the Organization when "send": true is set. You can also define a custom message with each call by setting "send": { "message": "Custom message" }, or by updating the Organization's Default invoice email message.


Want to download a PDF instead? Check the Download PDFs endpoint.


Read the full Document documentation >
Read the full Payment documentation >

      
        const response = await fetch('https://api.spaceinvoices.com/v1/Organizations/{id}/Documents', {
  method: 'POST',
  headers: {
    "Authorization": "ACCESS_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "type": "invoice",
    "_documentClient": {
      "name": "Rocket man",
      "country": "United Kingdom",
      "email": "[email protected]"
    },
    "_documentItems": [
      {
        "name": "Space suit",
        "quantity": 1,
        "price": 10000,
        "_documentItemTaxes": [
          {
            "rate": 21
          }
        ]
      }
    ],
    "payments": [
      {
        "type": "card"
      }
    ],
    "send": true
  })
});      
    

Your access token is displayed in examples.

Prerequisite: npm install node-fetch

        
          curl -X POST 'https://api.spaceinvoices.com/v1/Organizations/{id}/Documents' \
  -H 'Authorization: ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "type": "invoice",
    "_documentClient": {
      "name": "Rocket man",
      "country": "United Kingdom",
      "email": "[email protected]"
    },
    "_documentItems": [
      {
        "name": "Space suit",
        "quantity": 1,
        "price": 10000,
        "_documentItemTaxes": [
          {
            "rate": 21
          }
        ]
      }
    ],
    "payments": [
      {
        "type": "card"
      }
    ],
    "send": true
  }'        
      

Your access token displayed in examples.

        
          import requests
url = "https://api.spaceinvoices.com/v1/Organizations/{id}/Documents"
headers = {
  'Authorization': 'ACCESS_TOKEN',
  'Content-Type': 'application/json'
}
payload = {
  'type': 'invoice',
  '_documentClient': {
    'name': 'Rocket man',
    'country': 'United Kingdom',
    'email': '[email protected]'
  },
  '_documentItems': [
    {
      'name': 'Space suit',
      'quantity': 1,
      'price': 10000,
      '_documentItemTaxes': [
        {
          'rate': 21
        }
      ]
    }
  ],
  'payments': [
    {
      'type': 'card'
    }
  ],
  'send': true
}
response = requests.post(url, json=payload, headers=headers)        
      

Your access token displayed in examples.

Response:

    
      {
  "id": "644e072bf09b31001c381561",
  "number": "2023-00001",
  "draft": false,
  "date": "2023-04-30T06:14:03.266Z",
  "dateService": "2023-04-30T06:14:03.266Z",
  "dateDue": "2023-05-30T06:14:03.266Z",
  "reference": "",
  "total": 10000,
  "totalDiscount": 0,
  "totalWithTax": 12100,
  "decimalPlaces": 9,
  "note": "Please pay to bank account .\nWhen paying please use reference 2023-00002.\n\n\n\nThank you for your business",
  "taxClause": "",
  "footer": "International Space Agency, Rocket street 1, 10000 Brussels, Belgium",
  "signature": "International Space Agency",
  "type": "invoice",
  "canceled": false,
  "sentSnailMail": false,
  "totalPaid": 12100,
  "totalDue": 0,
  "paidInFull": true,
  "currencyId": "EUR",
  "_documentTaxes": [
    {
      "tax": 21,
      "taxId": "644c214d6ee48100249d5d7e",
      "abbreviation": "BTW 21%",
      "base": 10000,
      "totalTax": 2100
    }
  ],
  "_documentReverseTaxes": [],
  "hasUnit": false,
  "isValidEslog": false,
  "incoming": false,
  "issuedAt": "2023-04-30T06:14:03.296Z",
  "dateYear": 2023,
  "documentIds": [],
  "createdAt": "2023-04-30T06:14:03.339Z",
  "updatedAt": "2023-04-30T06:14:03.339Z",
  "custom": {},
  "_isDeleted": false,
  "_documentItems": [
    {
      "id": "7cfd524f-cb58-48b6-a61a-790f736b4dbe",
      "discount": 0,
      "discountIsAmount": false,
      "quantity": 1,
      "total": 10000,
      "totalWithTax": 12100,
      "totalTax": 2100,
      "totalDiscount": 0,
      "isSeparator": false,
      "name": "Space suit",
      "description": "",
      "price": 10000,
      "trackInventory": false,
      "custom": {},
      "_documentItemTaxes": [
        {
          "id": "75712b27-f506-4382-9de2-e2ab5434c57a",
          "rate": 21,
          "reverseCharged": false,
          "name": "Belasting over de toegevoegde waarde",
          "abbreviation": "BTW 21%",
          "recoverable": true,
          "compound": false,
          "taxId": "644c214d6ee48100249d5d7e"
        }
      ],
      "_components": [],
      "_data": []
    }
  ],
  "_documentIssuer": {
    "id": "bed479af-17e7-4df6-883e-bba92fb54f51",
    "name": "International Space Agency",
    "address": "Rocket street 1",
    "address2": "",
    "city": "Brussels",
    "zip": "10000",
    "country": "Belgium",
    "countryAlpha2Code": "BE",
    "taxNumber": "",
    "companyNumber": "",
    "IBAN": "",
    "bank": "",
    "SWIFT": "",
    "createdAt": "2023-04-28T19:41:00.930Z",
    "updatedAt": "2023-04-28T19:41:00.930Z",
    "custom": {},
    "_data": []
  },
  "clientId": "644e072bf09b31001c381560",
  "_documentClient": {
    "id": "813a3362-8e8b-4b3b-9730-1cce33572038",
    "isEndCustomer": false,
    "name": "Rocket man",
    "country": "United Kingdom",
    "countryAlpha2Code": "GB",
    "email": "[email protected]",
    "createdAt": "2023-04-30T06:14:03.339Z",
    "updatedAt": "2023-04-30T06:14:03.339Z",
    "custom": {},
    "_data": []
  },
  "organizationId": "644c214c6ee48100249d5d7d",
  "accountId": "62443617e71d701784024fe5",
  "_comments": [],
  "_data": [],
  "payments": [
    {
      "amount": 12100,
      "type": "card",
      "date": "2023-04-30T06:14:03.266Z",
      "id": "644e072bf09b31001c381562",
      "documentId": "644e072bf09b31001c381561",
      "organizationId": "644c214c6ee48100249d5d7d",
      "_isDeleted": false,
      "createdAt": "2023-04-30T06:14:03.395Z",
      "updatedAt": "2023-04-30T06:14:03.395Z",
      "custom": {}
    }
  ],
  "pdf": "https://api.spaceinvoices.com/v1/documents/644e072bf09b31001c381561/pdf"
}    
  

Conclusion

Congratulations! You've successfully created an Account, set up an Organization, generated an Invoice, and sent it to the Client using the Space Invoices API.

You can now explore other API endpoints and features to further customize and manage your invoices. Don't forget to consult the API documentation for additional details on available endpoints, parameters, and best practices.


Advanced use: Creating and managing Organizations for your users and issue invoices in their name: