Cost codes
Cost codes for job and project costing.
The object#
| Field | Type | Description |
|---|---|---|
| idread-only | integer | NolaPro id. |
| code | string(20) | The code. |
| description | string(255) | Label. |
| blocksales | boolean | Blocked from use on sales. |
| inactive | boolean | Not in use. Distinct from cancel. |
| cancel | boolean | True once cancelled. |
| externalid | string(100) | Your own key for this cost codes. Scoped to your company. |
Endpoints#
POST/costcodes/batch
207
Create many.
Requires scope glaccounts:write.
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
Body array
| Field | Type | Description |
|---|---|---|
| idread-only | integer | NolaPro id. |
| code | string(20) | The code. |
| description | string(255) | Label. |
| blocksales | boolean | Blocked from use on sales. |
| inactive | boolean | Not in use. Distinct from cancel. |
| cancel | boolean | True once cancelled. |
| externalid | string(100) | Your own key for this cost codes. Scoped to your company. |
curl -X POST \ 'https://acme.nolapro.com/!/api/v2/costcodes/batch' \ -H 'Authorization: Bearer $NP_TOKEN' \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: your-unique-key' \ -d '[ { "id": 4, "code": "LAB", "description": "Labour", "blocksales": false, "inactive": false, "cancel": false } ]'
$ch = curl_init('https://acme.nolapro.com/!/api/v2/costcodes/batch'); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('NP_TOKEN')], CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode([ [ 'id' => 4, 'code' => 'LAB', 'description' => 'Labour', 'blocksales' => false, 'inactive' => false, 'cancel' => false, ], ]), ]); $res = json_decode(curl_exec($ch), true);
import os, requests r = requests.post( "https://acme.nolapro.com/!/api/v2/costcodes/batch", headers={"Authorization": f"Bearer {os.environ['NP_TOKEN']}"}, json=[ { "id": 4, "code": "LAB", "description": "Labour", "blocksales": False, "inactive": False, "cancel": False, }, ], ) r.raise_for_status()
const res = await fetch( 'https://acme.nolapro.com/!/api/v2/costcodes/batch', { method: 'POST', headers: { Authorization: `Bearer ${process.env.NP_TOKEN}` }, body: JSON.stringify([ { id: 4, code: "LAB", description: "Labour", blocksales: false, inactive: false, cancel: false, }, ]), } ); const data = await res.json();
using System.Net.Http.Json; var token = Environment.GetEnvironmentVariable("NP_TOKEN"); using var http = new HttpClient(); http.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var body = new[] { new { id = 4, code = "LAB", description = "Labour", blocksales = false, inactive = false, cancel = false, }, }; var req = new HttpRequestMessage(HttpMethod.Post, "https://acme.nolapro.com/!/api/v2/costcodes/batch") { Content = JsonContent.Create(body), }; req.Headers.Add("Idempotency-Key", "your-unique-key"); var res = await http.SendAsync(req); res.EnsureSuccessStatusCode();
GET/costcodes
200403
List cost codes.
Requires scope glaccounts:read.
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
| description | query | string | description. Partial match, case-insensitive. |
| code | query | string | code. Partial match, case-insensitive. |
| cancel | query | string | Defaults to false. Pass true or any. |
| externalid | query | string | Exact match on your own key. Scoped to your company. |
| include | query | string | Comma-separated extras to embed. Only custom_fields is available: the extra fields this install has defined on the record. Off by default, and an unrecognised value is refused rather than ignored. See Conventions. |
When it fails
| Status | Code | Meaning |
|---|---|---|
| 403 | insufficient_scope | Token lacks costcodes:read. |
curl \ 'https://acme.nolapro.com/!/api/v2/costcodes' \ -H 'Authorization: Bearer $NP_TOKEN'
$ch = curl_init('https://acme.nolapro.com/!/api/v2/costcodes'); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('NP_TOKEN')], CURLOPT_RETURNTRANSFER => true, ]); $res = json_decode(curl_exec($ch), true);
import os, requests r = requests.get( "https://acme.nolapro.com/!/api/v2/costcodes", headers={"Authorization": f"Bearer {os.environ['NP_TOKEN']}"}, ) r.raise_for_status()
const res = await fetch( 'https://acme.nolapro.com/!/api/v2/costcodes', { method: 'GET', headers: { Authorization: `Bearer ${process.env.NP_TOKEN}` }, } ); const data = await res.json();
using System.Net.Http.Json; var token = Environment.GetEnvironmentVariable("NP_TOKEN"); using var http = new HttpClient(); http.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var res = await http.GetAsync( "https://acme.nolapro.com/!/api/v2/costcodes"); res.EnsureSuccessStatusCode();
POST/costcodes
201400409
Create.
Requires scope glaccounts:write.
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
Body
| Field | Type | Description |
|---|---|---|
| idread-only | integer | NolaPro id. |
| code | string(20) | The code. |
| description | string(255) | Label. |
| blocksales | boolean | Blocked from use on sales. |
| inactive | boolean | Not in use. Distinct from cancel. |
| cancel | boolean | True once cancelled. |
| externalid | string(100) | Your own key for this cost codes. Scoped to your company. |
When it fails
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | A required field was missing. |
| 409 | duplicate | That code is already in use. |
curl -X POST \ 'https://acme.nolapro.com/!/api/v2/costcodes' \ -H 'Authorization: Bearer $NP_TOKEN' \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: your-unique-key' \ -d '{ "id": 4, "code": "LAB", "description": "Labour", "blocksales": false, "inactive": false, "cancel": false }'
$ch = curl_init('https://acme.nolapro.com/!/api/v2/costcodes'); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('NP_TOKEN')], CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => json_encode([ 'id' => 4, 'code' => 'LAB', 'description' => 'Labour', 'blocksales' => false, 'inactive' => false, 'cancel' => false, ]), ]); $res = json_decode(curl_exec($ch), true);
import os, requests r = requests.post( "https://acme.nolapro.com/!/api/v2/costcodes", headers={"Authorization": f"Bearer {os.environ['NP_TOKEN']}"}, json={ "id": 4, "code": "LAB", "description": "Labour", "blocksales": False, "inactive": False, "cancel": False, }, ) r.raise_for_status()
const res = await fetch( 'https://acme.nolapro.com/!/api/v2/costcodes', { method: 'POST', headers: { Authorization: `Bearer ${process.env.NP_TOKEN}` }, body: JSON.stringify({ id: 4, code: "LAB", description: "Labour", blocksales: false, inactive: false, cancel: false, }), } ); const data = await res.json();
using System.Net.Http.Json; var token = Environment.GetEnvironmentVariable("NP_TOKEN"); using var http = new HttpClient(); http.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var body = new { id = 4, code = "LAB", description = "Labour", blocksales = false, inactive = false, cancel = false, }; var req = new HttpRequestMessage(HttpMethod.Post, "https://acme.nolapro.com/!/api/v2/costcodes") { Content = JsonContent.Create(body), }; req.Headers.Add("Idempotency-Key", "your-unique-key"); var res = await http.SendAsync(req); res.EnsureSuccessStatusCode();
Response 201
{
"id": 4,
"code": "LAB",
"description": "Labour",
"blocksales": false,
"inactive": false,
"cancel": false
}
GET/costcodes/{id}
200404
Retrieve one record.
Requires scope glaccounts:read.
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
| idrequired | path | integer | The record id. |
| include | query | string | Comma-separated extras to embed. Only custom_fields is available: the extra fields this install has defined on the record. Off by default, and an unrecognised value is refused rather than ignored. See Conventions. |
When it fails
| Status | Code | Meaning |
|---|---|---|
| 404 | not_found | No record with that id. |
curl \ 'https://acme.nolapro.com/!/api/v2/costcodes/104' \ -H 'Authorization: Bearer $NP_TOKEN'
$ch = curl_init('https://acme.nolapro.com/!/api/v2/costcodes/104'); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('NP_TOKEN')], CURLOPT_RETURNTRANSFER => true, ]); $res = json_decode(curl_exec($ch), true);
import os, requests r = requests.get( "https://acme.nolapro.com/!/api/v2/costcodes/104", headers={"Authorization": f"Bearer {os.environ['NP_TOKEN']}"}, ) r.raise_for_status()
const res = await fetch( 'https://acme.nolapro.com/!/api/v2/costcodes/104', { method: 'GET', headers: { Authorization: `Bearer ${process.env.NP_TOKEN}` }, } ); const data = await res.json();
using System.Net.Http.Json; var token = Environment.GetEnvironmentVariable("NP_TOKEN"); using var http = new HttpClient(); http.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var res = await http.GetAsync( "https://acme.nolapro.com/!/api/v2/costcodes/104"); res.EnsureSuccessStatusCode();
Response 200
{
"id": 4,
"code": "LAB",
"description": "Labour",
"blocksales": false,
"inactive": false,
"cancel": false
}
PATCH/costcodes/{id}
200404409
Update.
Requires scope glaccounts:write.
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
| idrequired | path | integer | The record id. |
Body
| Field | Type | Description |
|---|---|---|
| idread-only | integer | NolaPro id. |
| code | string(20) | The code. |
| description | string(255) | Label. |
| blocksales | boolean | Blocked from use on sales. |
| inactive | boolean | Not in use. Distinct from cancel. |
| cancel | boolean | True once cancelled. |
| externalid | string(100) | Your own key for this cost codes. Scoped to your company. |
When it fails
| Status | Code | Meaning |
|---|---|---|
| 404 | not_found | No record with that id. |
| 409 | stale_record | If-Match did not match. |
curl -X PATCH \ 'https://acme.nolapro.com/!/api/v2/costcodes/104' \ -H 'Authorization: Bearer $NP_TOKEN' \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: your-unique-key' \ -d '{ "id": 4, "code": "LAB", "description": "Labour", "blocksales": false, "inactive": false, "cancel": false }'
$ch = curl_init('https://acme.nolapro.com/!/api/v2/costcodes/104'); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('NP_TOKEN')], CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'PATCH', CURLOPT_POSTFIELDS => json_encode([ 'id' => 4, 'code' => 'LAB', 'description' => 'Labour', 'blocksales' => false, 'inactive' => false, 'cancel' => false, ]), ]); $res = json_decode(curl_exec($ch), true);
import os, requests r = requests.patch( "https://acme.nolapro.com/!/api/v2/costcodes/104", headers={"Authorization": f"Bearer {os.environ['NP_TOKEN']}"}, json={ "id": 4, "code": "LAB", "description": "Labour", "blocksales": False, "inactive": False, "cancel": False, }, ) r.raise_for_status()
const res = await fetch( 'https://acme.nolapro.com/!/api/v2/costcodes/104', { method: 'PATCH', headers: { Authorization: `Bearer ${process.env.NP_TOKEN}` }, body: JSON.stringify({ id: 4, code: "LAB", description: "Labour", blocksales: false, inactive: false, cancel: false, }), } ); const data = await res.json();
using System.Net.Http.Json; var token = Environment.GetEnvironmentVariable("NP_TOKEN"); using var http = new HttpClient(); http.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var body = new { id = 4, code = "LAB", description = "Labour", blocksales = false, inactive = false, cancel = false, }; var req = new HttpRequestMessage(HttpMethod.Patch, "https://acme.nolapro.com/!/api/v2/costcodes/104") { Content = JsonContent.Create(body), }; req.Headers.Add("Idempotency-Key", "your-unique-key"); var res = await http.SendAsync(req); res.EnsureSuccessStatusCode();
Response 200
{
"id": 4,
"code": "LAB",
"description": "Labour",
"blocksales": false,
"inactive": false,
"cancel": false
}
DELETE/costcodes/{id}
200403404
Cancel.
Requires scope glaccounts:cancel.
Parameters
| Name | In | Type | Notes |
|---|---|---|---|
| idrequired | path | integer | The record id. |
When it fails
| Status | Code | Meaning |
|---|---|---|
| 403 | insufficient_scope | Needs costcodes:cancel. |
| 404 | not_found | No record with that id. |
curl -X DELETE \ 'https://acme.nolapro.com/!/api/v2/costcodes/104' \ -H 'Authorization: Bearer $NP_TOKEN'
$ch = curl_init('https://acme.nolapro.com/!/api/v2/costcodes/104'); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('NP_TOKEN')], CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'DELETE', ]); $res = json_decode(curl_exec($ch), true);
import os, requests r = requests.delete( "https://acme.nolapro.com/!/api/v2/costcodes/104", headers={"Authorization": f"Bearer {os.environ['NP_TOKEN']}"}, ) r.raise_for_status()
const res = await fetch( 'https://acme.nolapro.com/!/api/v2/costcodes/104', { method: 'DELETE', headers: { Authorization: `Bearer ${process.env.NP_TOKEN}` }, } ); const data = await res.json();
using System.Net.Http.Json; var token = Environment.GetEnvironmentVariable("NP_TOKEN"); using var http = new HttpClient(); http.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); var req = new HttpRequestMessage(HttpMethod.Delete, "https://acme.nolapro.com/!/api/v2/costcodes/104"); var res = await http.SendAsync(req); res.EnsureSuccessStatusCode();
Response 200
{
"id": 4,
"code": "LAB",
"description": "Labour",
"blocksales": false,
"inactive": false,
"cancel": false
}