sales_invoices

The following resources are applicable:

/sales_invoices

Mount Point: /rest/v2/sales_invoices

The following operations are supported on this resource:

GET

RESTful service to retrieve all of the available sales invoices URL. e.g. performing a HTTP GET request to: http://<crunch api url>/rest/v2/sales_invoices will return all list of sales invoices.

Parameters

name description type default
firstResult Optional, defaults to 0

Used for pagination, the firstResult query parameter specifies the first record to be returned by the 'List All Sales Invoices' end point. The parameter is 0 index-based, and so if requesting the first sales invoice in the list of sales invoices, firstResult should be set to 0.

The firstResult parameter is optional, and the default value for firstResult is 0. If specified, firstResult should be set to any non-negative integer.

query 0
resultsPerPage Optional, defaults to 0

Used for pagination, the resultsPerPage query parameter specifies the maximum number of results returned by the 'List All Sales Invoices' service.

The resultsPerPage parameter is relative to the firstResult parameter - therefore if firstResult is set to 0 and resultsPerPage is set to 10, then only the first 10 sales invoices from the overall list of sales invoices will be returned.

If firstResult is set to 10 and resultsPerPage is set to 10, then the service will return the next 10 records (i.e the sales invoices at positions 10 to 19 in the complete list of sales invoices).

The resultsPerPage parameter is optional. If no value is provided the service will return the entire result set - i.e. all sales invoices in the account. Valid values for resultsPerPage are any positive integer value, so any integer greater than or equal to 1.

query
state Valid states are Draft, Due, Overdue, Settled and Written_Off

Used to filter the list of sales invoices returned by the state.

The state query parameter can contain multiple states, and these states should be comma separated.As an example, if the state query parameter was specified as below:

state=due,overdue

The service would only return sales invoices that have been issued and not paid.If the state query parameter specified draft, then only invoices that have not been issued would be returned.

query
clientId Optional, defaults to empty string query
clientRef Optional, defaults to empty string query
dueDate Optional, defaults to empty string query
dueDateFrom Optional, defaults to empty string query
dueDateTo Optional, defaults to empty string query

Response Body

element: salesInvoices
media types: application/xml
application/json

SalesInvoices or Errors

Status Codes

HTTP Status Code Description
200 OK SalesInvoices found
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred

POST

RESTful service to create a sales invoice to the resource URL, i.e. performing a HTTP POST request to: http://<crunch api url>/rest/v2/sales_invoices will create a sales invoice. The id of the newly created sales invoice will be returned.

Request Body

element: salesInvoice
media types: */*
application/xml

The sales invoice to add

Response Body

element: (custom)
media types: application/xml
application/json

SalesInvoice (with only the newly created SalesInvoice ID set) or Errors

Status Codes

HTTP Status Code Description
201 Created SalesInvoice added
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred

OPTIONS

Options call to handle CORS requests (typically coming from javascript frameworks like jQuery) See here for further information.

Response Body

element: (custom)
media types: */*
application/xml

(no documentation provided)

/sales_invoices/{salesInvoiceId}

Mount Point: /rest/v2/sales_invoices/{salesInvoiceId}

The following operations are supported on this resource:

GET

RESTful service to retrieve all of the available sales invoice details for the sales invoice who's ID is specified as the last element to the resource URL. e.g. performing a HTTP GET request to: http://<crunch api url>/rest/v2/sales_invoices/1 will return the sales invoice who's id is 1. The id of the sales invoice can be found within the listing of expenses retrieved from the /salesinvoices service.

Parameters

name description type default
salesInvoiceId Id of the requested sales invoice. path

Response Body

element: (custom)
media types: application/xml
application/json

SalesInvoice or Errors

Status Codes

HTTP Status Code Description
200 OK SalesInvoice found
404 Not Found SalesInvoice not found
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred

PUT

RESTful service to update a sales invoice to the resource URL, i.e. performing a HTTP PUT request to: http://<crunch api url>/rest/v2/sales_invoices/{salesInvoiceId} will update a sales invoice. The id of the updated sales invoice will be returned.

Parameters

name description type default
salesInvoiceId The id of the sales invoice to be updated. path

Request Body

element: salesInvoice
media types: */*
application/xml

The sales invoice to update

Response Body

element: (custom)
media types: application/xml
application/json

SalesInvoice (with only the updated SalesInvoice ID set) or Errors

Status Codes

HTTP Status Code Description
201 Created SalesInvoice updated
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred

DELETE

The salesInvoice/{salesInvoiceId} DELETE REST service end point deletes a specific sales invoice based on the ID specified

Parameters

name description type default
salesInvoiceId The ID of the sales invoice to be deleted. path

Response Body

element: (custom)
media types: application/xml
application/json

empty body or Errors

Status Codes

HTTP Status Code Description
204 No Content SalesInvoice deleted
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred

/sales_invoices/{salesInvoiceId}/{action}

Mount Point: /rest/v2/sales_invoices/{salesInvoiceId}/{action}

PUT

RESTful service to issue or email a sales invoice, i.e. performing a HTTP PUT request to: http://<crunch api url>/rest/v2/sales_invoices/{id}/{action} will issue/email a sales invoice depending whether the action parameter is set to email or issue.

Parameters

name description type default
salesInvoiceId The ID of the sales invoice to be emailed or issued. path
action Valid values are email and issue. path

Response Body

element: (custom)
media types: application/xml
application/json

empty body or Errors

Status Codes

HTTP Status Code Description
204 No Content SalesInvoice emailed
204 No Content SalesInvoice issued
404 Not Found SalesInvoice not found
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred

/sales_invoices/{salesInvoiceId}/document

Mount Point: /rest/v2/sales_invoices/{salesInvoiceId}/document

GET

RESTful service to retrieve all of the available sales invoice details for the sales invoice who's ID is specified, including full document information (i.e. the pdf for that sales invoice).

Parameters

name description type default
salesInvoiceId Get the document associated with the id of the sales invoice. path

Response Body

element: (custom)
media types: application/xml
application/json

SalesInvoice (with attached document) or Errors

Status Codes

HTTP Status Code Description
200 OK SalesInvoice (with document attached) found
404 Not Found SalesInvoice not found
400 Bad Request Invalid input, returns message body of Errors
500 Internal Server Error A database error has occurred