Quick Start Guide

This guide is intended to help you understand the basic features of the Space Invoices API and to get up and running with invoicing with just a couple of steps.


1. Create an Account

Signup for a Space Invoices master Account here, if you haven't already, you'll need it to start making API calls.

It's also recommended to log into Space Invoices as your launch code (access token) will be automatically populated in all documentation examples.

Additional accounts can be created using the master account's access token.

                          
                            let response = await fetch('https://api.spaceinvoices.com/v1/accounts/ACCOUNT_ID', {
                              method: 'POST',
                              headers: {
                                Authorization: 'TOKEN',
                              },
                              body: {
                                email: '[email protected]',
                                password: 'supersecret',
                              },
                            });
                          
                        

Your access token populated in examples.

Prerequisite: npm install fetch

                            
                              curl https://api.spaceinvoices.com/v1/accounts/ACCOUNT_ID \
                                -H "Authorization: TOKEN" \
                                -d '{ \
                                  "email": "[email protected]" \
                                  "password": "supersecret" \
                                }'
                            
                          

Your access token populated in examples.

                            
                              import requests
                              url = 'https://api.spaceinvoices.com/v1/accounts/ACCOUNT_ID'
                              headers = {
                                  'Authorization': 'TOKEN'
                              }
                              body = {
                                  'email': '[email protected]',
                                  'password': 'supersecret',
                              }
                              response = requests.post(url, data=body, headers=headers)

                            
                          

Your access token populated in examples.

2. Create an Organization

Organizations are the central unit of all other resources in the API, you'll need one to issue invoices.

An organization can be created on the Space Invoices website, or using the following API call:

                  
                    let response = await fetch('https://api.spaceinvoices.com/v1/accounts/ACCOUNT_ID/organizations', {
                      method: 'POST',
                      headers: {
                        Authorization: 'TOKEN',
                      },
                      body: {
                        name: 'International Space Agency',
                        city: "Brussels",
                        zip: "10000",
                        country: 'Belgium',
                      },
                    });
                  
                

Your access token populated in examples.

Prerequisite: npm install fetch

                    
                      curl https://api.spaceinvoices.com/v1/organizations/ORGANIZATION_ID/documents \
                        -H "Authorization: TOKEN" \
                        -d '{ \
                          "name": "International Space Agency" \
                          "address": "Rocket Road 1" \
                          "city": "Brussels" \
                          "zip": 10000,
                          "country": "Belgium" \
                        }'
                    
                  

Your access token populated in examples.

                    
                      import requests
                      url = 'https://api.spaceinvoices.com/v1/accounts/ACCOUNT_ID/organizations'
                      headers = {
                          'Authorization': 'TOKEN'
                      }
                      body = {
                          'name': 'International Space Agency',
                          'city': 'Brussels',
                          'zip': '10000',
                          'country': 'Belgium',
                      }
                      response = requests.post(url, data=body, headers=headers)

                    
                  

Your access token populated in examples.

NOTE: Space Invoices supports multi-tenant management, meaning an account can be granted access to multiple organizations, each organization represents a legal entity like a business, NGO, club, and similar.

3. Create an Invoice

Create your first Invoice using the following API call:

                  
                    let response = await fetch('https://api.spaceinvoices.com/v1/organizations/ORGANIZATION_ID/documents', {
                      method: 'POST',
                      headers: {
                        Authorization: 'TOKEN',
                      },
                      body: {
                        type: 'invoice',
                        _documentClient: {
                          name: 'Rocket man',
                          email: '[email protected]',
                          country: 'USA'
                        },
                        _documentItems: [{
                          name: 'Space suit',
                          country: 19500,
                          country: 1
                        }],
                        send: true,
                      },
                    });
                  
                

Your access token populated in examples.

Prerequisite: npm install fetch

                    
                      curl https://api.spaceinvoices.com/v1/organizations/ORGANIZATION_ID/documents \
                        -H "Authorization: TOKEN" \
                        -d '{ \
                          "type": "invoice" \
                          "_documentClient": { \
                            "name": "Rocket man", \
                            "email": "[email protected]", \
                            "country": "USA" \
                          }, \
                          "_documentItems": [{ \
                            "name": "Space suit", \
                            "quantity": 1, \
                            "price": 19500 \
                          }], \
                          "send": true \
                        }'
                    
                  

Your access token populated in examples.

                    
                      import requests
                      url = 'https://api.spaceinvoices.com/v1/organizations/ORGANIZATION_ID/documents'
                      headers = {
                          'Authorization': 'TOKEN'
                      }
                      body = {
                          'type': 'invoice',
                          '_documentClient': {
                              'name': 'Rocket man',
                              'email': '[email protected]',
                              'country': 'USA'
                          },
                          '_documentItems': [{
                              'name': 'Space suit',
                              'country': 19500,
                              'country': 1
                          }],
                          'send': True,
                      }
                      response = requests.post(url, data=body, headers=headers)

                    
                  

Your access token populated in examples.

Congratulations! You have just created and sent your first invoice!

NOTE: By including the `send` property the document is automatically sent the the client after it's created. The content of the email sent to the client is set based on predefined defaults set when the organization is created, those defaults can be updated or be specified for each document individual by sending the `send` property as an object containing `subject` and `message` properties.

Bonus: Add Payment to the created Invoice

After an invoice has been paid we can add a payment to it to mark it as paid.

                  
                    let response = await fetch('https://api.spaceinvoices.com/v1/documents/DOCUMENT_ID/payments', {
                      method: 'POST',
                      headers: {
                        Authorization: 'TOKEN',
                      },
                      body: {
                        amount: 19500,
                        type: 'card',
                      },
                    });
                  
                

Your access token populated in examples.

Prerequisite: npm install fetch

                    
                      curl https://api.spaceinvoices.com/v1/documents/DOCUMENT_ID/payments \
                        -H "Authorization: TOKEN" \
                        -d '{ \
                          "amount": 19500 \
                          "type": "card" \
                        }'
                    
                  

Your access token populated in examples.

                    
                      import requests
                      url = 'https://api.spaceinvoices.com/v1/documents/DOCUMENT_ID/payments'
                      headers = {
                          'Authorization': 'TOKEN'
                      }
                      body = {
                          'amount': 19500,
                          'type': 'card',
                      }
                      response = requests.post(url, data=body, headers=headers)

                    
                  

Your access token populated in examples.

NOTE: A document can be marked as paid in the same call as it is created, simply add a `payments` Array property to the document create body with the same properties as when adding a payment separately. When creating a payment in this way the `amount` property can be ommitted if the document is fully paid as the API will fill the amount automatically.