This article lists the ToolWatch API requests for cost codes: Create, Retrieve, Retrieve List, and Update. Every request needs an authorization token. To get one, see ToolWatch API: Authorization.
Create
Request
URI
https://api.{cluster}.toolwatch.net/costcodesHttp Method
POST
Headers
Authorization: {token}
Request Body
Field | Type | Required | Description |
Description | string | Yes | Cost code description. Max 50 characters. |
Number | string | Yes | Cost code number. Max 25 characters. |
CostCenterId | guid | No | Associated cost center id. |
Inactive | boolean | No | Whether the cost code is inactive. |
CodeGroup | string | No | Code group. |
Response
201 Created
The response header contains the URI for the newly created cost code.
Location: https://api.{cluster}.toolwatch.net/costcodes/{id}400 Bad Request
Triggered when field level validation fails.
Response body will contain validation message
[
{
"PropertyName": "Number",
"Message": "Please provide a cost code number.",
"AttemptedValue": ""
}
]
Retrieve
Request
URI
https://api.{cluster}.toolwatch.net/costcodes/{id}Allowable querystring parameters
Parameter | Description |
columns | Comma-separated list of properties to return. |
Http Method
GET
Headers
Authorization: {token}
Request Body
Not allowed for GET
Response
200 Ok
By default every property is returned. Use the columns querystring parameter to limit the response to specific properties.
Field | Type | Description |
Id | guid | Unique identifier. |
Description | string | Cost code description. |
Number | string | Cost code number. |
CostCenterId | guid | Associated cost center id. |
Inactive | boolean | Whether the cost code is inactive. |
CodeGroup | string | Code group. |
Example response body:
{
"Id": "{id}",
"Description": "Cost Code",
"Number": "Cost Code Number",
"CodeGroup": "Code Group",
"Inactive": false
}404 Not Found
Triggered when id parameter is not a valid guid or no matching record was found.
Response body will contain error message
{id} is not a valid cost code id.Retrieve List
Request
URI
https://api.{cluster}.toolwatch.net/costcodesAllowable querystring parameters
Parameter | Description |
columns | Comma-separated list of properties to return. |
number | Filter by cost code number. |
Http Method
GET
Headers
Authorization: {token}
Request Body
Not allowed for GET
Response
200 Ok
By default every property is returned. Use the columns querystring parameter to limit the response to specific properties.
Field | Type | Description |
Id | guid | Unique identifier. |
Description | string | Cost code description. |
Number | string | Cost code number. |
CostCenterId | guid | Associated cost center id. |
Inactive | boolean | Whether the cost code is inactive. |
CodeGroup | string | Code group. |
Example response body:
[
{
"Id": "849197e3-6cc4-4150-ae71-3f2fc1fbc53d",
"Description": "Cost Code 1",
"Number": "Cost Code Number 1",
"CodeGroup": "Code Group 1",
"Inactive": false
},
{
"Id": "cc09dbb0-6cc4-4150-ae71-3f2fc1fbc53d",
"Description": "Cost Code 2",
"Number": "Cost Code Number 2",
"CodeGroup": "Code Group 2",
"Inactive": false
}
]
404 Not Found
Triggered when field parameters in querystring are not allowed.
Response body will contain error message
{"Message":"Criteria is invalid","Type":"Exception"}Update
Request
URI
https://api.{cluster}.toolwatch.net/costcodes/{id}Http Method
PUT
Headers
Authorization: {token}
Request Body
Supply the model completely. Any property that is omitted is overwritten with its default value.
Field | Type | Required | Description |
Description | string | Yes | Cost code description. Max 50 characters. |
Number | string | Yes | Cost code number. Max 25 characters. |
CostCenterId | guid | No | Associated cost center id. |
Inactive | boolean | No | Whether the cost code is inactive. |
CodeGroup | string | No | Code group. |
Response
200 Ok
400 Bad Request
Triggered when field level validation fails.
Response body will contain validation message
[
{
"PropertyName": "Number",
"Message": "Please provide a cost code number.",
"AttemptedValue": ""
}
]
404 Not Found
Triggered when id parameter is not a valid guid or no matching record was found.
Response body will contain error message
{id} is not a valid cost code id.