Skip to main content

Create Supplier Payment (v1)

Method & Path

POST /api/v1/workspace/:workspaceId/suppliers/:supplierId/payments

Actual backend path: POST /v1/workspace/:workspaceId/suppliers/:supplierId/payments

Description

Create a new payment for a supplier. Optionally link to an invoice via invoiceId; the backend will update the invoice’s paid/remaining amounts and status.

Authentication

Required: Workspace JWT.

Persona access

  • Workspace Owner: Allowed (suppliers section enabled for workspace).
  • Staff: Allowed when suppliers access is granted via workspace menu/permissions.
  • Admin / Customer: Not applicable for this client workspace API.

Headers

HeaderRequiredDescription
AuthorizationYesBearer <workspace_token>
Content-TypeYesapplication/json

Path Parameters

ParameterTypeRequiredDescription
workspaceIdstringYesWorkspace identifier
supplierIdstringYesSupplier identifier

Request Body

{
"invoiceId": "507f1f77bcf86cd799439021",
"amount": 2000,
"paymentDate": "2024-01-20",
"paymentMethod": "bank-transfer",
"description": "دفعة أولى",
"notes": "ملاحظات",
"imageUrl": "https://storage.googleapis.com/bucket/path/to/receipt.webp"
}
FieldTypeRequiredDescription
invoiceIdstring or nullNoLink to supplier invoice (optional)
amountnumberYesMust be ≥ 0
paymentDatestring (date)YesDate of payment
paymentMethodstringYesOne of: cash, check, bank-transfer, card, other
descriptionstringNoOptional description
notesstringNoOptional notes
imageUrlstring (URL) or nullNoOptional receipt image; upload via Upload supplier payment image first
note

To attach an image, call POST .../suppliers/:supplierId/payment-image with multipart field file, then include the returned HTTPS URL in imageUrl.

Response 201 Created

{
"payment": {
"id": "507f1f77bcf86cd799439031",
"workspaceId": "507f1f77bcf86cd799439012",
"supplierId": "507f1f77bcf86cd799439011",
"invoiceId": "507f1f77bcf86cd799439021",
"amount": 2000,
"paymentDate": "2024-01-20T00:00:00.000Z",
"paymentMethod": "bank-transfer",
"description": "دفعة أولى",
"notes": "ملاحظات",
"imageUrl": null,
"createdAt": "2024-01-20T10:00:00.000Z",
"updatedAt": "2024-01-20T10:00:00.000Z"
}
}

Common Errors

  • 400 Bad Request: Validation error
  • 401 Unauthorized: Missing or invalid token
  • 403 Forbidden: Workspace access denied
  • 404 Not Found: Workspace, supplier, or invoice (if provided) not found
  • 500 Internal Server Error: Server error