Update an Order
API usage example for updating an Order with Agency Handy API
Prerequisites
Review the steps in the Getting Started guide before updating an order. It walks through configuring your API token, and selecting the correct companyid, which are all required for the instructions below.
Endpoint
Method:
PUTPath:
{{URL}}/ordersQuery string:
pid=<projectId>(required)Content-Type:
multipart/form-data(use this even when no files are attached to satisfy themulterparser)
Authorization & Headers
Authorization
Yes
Bearer token for the signed-in member. Processed by the authorization middleware.
companyid
Yes
Mongo ObjectId of the company in which the order exists. Required by most services.
clientid
Optional
Real-time client socket id. If supplied, notification payloads include it.
Query Parameters
pid
string (ObjectId)
The order / project id that will be updated.
Request Body Schema
name
string (min 2)
Updates the project title.
deadline
ISO date
Adjusts the internal due date.
budget
number ≥ 0
Total budget figure (matches original currency).
quantity
number ≥ 1
Number of units purchased for the package.
currency
string
USD, CAD, EUR etc.
status
enum
One of Pending, Ongoing, Review, Completed, Cancelled. Business rules listed below.
kickoffDate
ISO date
Project start date.
notes
string
Internal notes.
brief
string
Client brief / summary.
assignedProjectManagers
array
Complete list of project manager member ids. New ids are added to the team; removed ids are deleted from the team. Each id must belong to a projectManager role inside the same company.
repeatCount
number
Required only for subscription orders when changing recurrence settings.
repeatDuration
enum
One of month, week, day, year. Required alongside repeatCount for subscription orders.
billingCycleCount
number
Optional recurring billing limit. Defaults to 0 (no limit).
billingCycleEvent
enum
Either createOrderWithTask or noChange.
markTasksAsDone
boolean
Required when status is Completed or Cancelled. When true, all project tasks are marked done after the status change.
rejectRequestedTasks
boolean
Allowed only when status is Completed or Cancelled. When true, any client-requested tasks are rejected after the update.
File Uploads
Attach zero or more files under the files field. Every upload is appended to the order's system folder and its byte size is added to the folder's sizeInBytes. When files are provided the handler:
Uploads each attachment through the standard order upload pipeline.
Accumulates the uploaded file sizes and increments the folder size atomically.
Leaves previously uploaded order files untouched.
Example JSON Payload
Use this structure when constructing the body (convert the fields to multipart form entries when including files):
Business Rules & Side Effects
Caller must be an approved member of the
companyid(userProjectListcheck). Unauthorized members receive403 PermissionError.Orders already marked
CancelledorCompletedcannot be updated (400 ValidationError).Members signed in as
clientcannot cancel an order once it has moved out ofPending(403 PermissionError).Status transitions are restricted:
Reviewcan only followOngoingor anotherReview. Trying to jump fromPending→Reviewreturns400 ValidationError.Changing status from
Pendingto any ofOngoing,Review, orCompletedmarks the project's folder as live (isLive: true).Setting
statustoCompletedorCancelledrequires an explicitmarkTasksAsDoneboolean. Whentrue, every task in the order is closed; whenfalse, tasks remain untouched.rejectRequestedTasksmay only betruewhen the order is transitioning toCompletedorCancelled. If enabled, all outstanding client-requested tasks are rejected after the update.Moving
statustoReview,Completed, orCancelledtriggers notifications:Review: notifies the client that a review is needed.Completed: sends theorderCompletionnotification to the client.Cancelled: sends theorderCancellationnotification to the client.
After every successful update, the system fires an
ORDER.UPDATEDwebhook event whose payload includes the updated project document plus the current attachment metadata.
Responses
200 OK
Update succeeded. Body: { "message": "Project has been updated" }.
400 ValidationError
Invalid project id, blocked status transition, or malformed payload. Response contains fieldName when relevant.
403 PermissionError
Member is not approved, lacks the company role, subscription expired, or a client attempted a forbidden cancel action.
500 Internal Server Error
Unhandled exceptions are forwarded to the error middleware and logged via Winston.
Example Request
Sample success response
Last updated
Was this helpful?