Add a Payment Term
This API endpoint allows you to add a new payment term.
HTTP Request
- URL:
/api/paymentTerms - Method:
POST - Headers:
Content-Type:application/jsonaccessToken: Required. This is your access token for authenticating the request.
Request Body
The request body should be a JSON object following the schema below:
| Field | Type | Description |
|---|---|---|
name | String | The name of the payment term. |
status | Boolean | Indicates if the payment term is active. |
dueType | String | Specifies the condition upon which the payment is due. Must be either net or fulfillment. |
paymentDueDays | Number | Required if dueType is net; specifies the number of days after the due type upon which payment is due. Optional if dueType is fulfillment. |
Sample Payload
{
"name": "Net 180",
"status": true,
"dueType": "net",
"paymentDueDays": 180
}
cURL Example
Below is a sample cURL command demonstrating how to make a request to the API endpoint:
curl --location 'http://localhost:3003/api/paymentTerms' \
--header 'Content-Type: application/json' \
--header 'accessToken: 6e482dd1194cea7e22df997ca6e5a60afb7af4ebb4f07db916d7470b03970959' \
--data '{
"name": "Net 180",
"status": true,
"dueType": "net",
"paymentDueDays": 180
}'
Response
- 201 Created: The payment term was successfully created, and the server returned the details of the new payment term.
- 4XX: Client errors indicating issues such as validation errors or missing required fields.
- 5XX: Server errors indicating that something went wrong on the server's end.
Sample JSON Response
Below is an example of the JSON response you might receive from successfully creating a new payment term:
{
"success": true,
"data": {
"name": "Net 180",
"status": true,
"dueType": "net",
"paymentDueDays": 180,
"_id": "67a46366869ddc960b432623",
"createdAt": "2025-02-06T07:23:18.394Z",
"updatedAt": "2025-02-06T07:23:18.394Z",
"__v": 0
}
}
Response Details
| Key | Type | Description |
|---|---|---|
success | Boolean | Indicates if the request was successful. |
data | Object | Contains the details of the newly created payment term. |
createdAt | String | Timestamp of when the payment term was created (in ISO 8601 format). |
updatedAt | String | Timestamp of when the payment term was last updated (in ISO 8601 format). |
Notes
- Ensure that the
accessTokenprovided is valid and has not expired. - Ensure the payload meets the validation criteria to avoid errors.