Skip to main content

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/json
    • accessToken: Required. This is your access token for authenticating the request.

Request Body

The request body should be a JSON object following the schema below:

FieldTypeDescription
nameStringThe name of the payment term.
statusBooleanIndicates if the payment term is active.
dueTypeStringSpecifies the condition upon which the payment is due. Must be either net or fulfillment.
paymentDueDaysNumberRequired 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

KeyTypeDescription
successBooleanIndicates if the request was successful.
dataObjectContains the details of the newly created payment term.
createdAtStringTimestamp of when the payment term was created (in ISO 8601 format).
updatedAtStringTimestamp of when the payment term was last updated (in ISO 8601 format).

Notes

  • Ensure that the accessToken provided is valid and has not expired.
  • Ensure the payload meets the validation criteria to avoid errors.