Tutorial: Edit a Contract¶
This tutorial shows how to update an existing contract using the public API wrapper in People Cloud. The public endpoint forwards the request to the internal update logic and attempts to preserve business behaviour (company resolution, consultant handling, validations).
Step 1: Make a POST Request to update a Contract¶
Send a POST request to the following public API endpoint (use the public id):
POST /api/v1/contracts/{the_contract_id}/edit
You can also address by numeric DB id:
POST /api/v1/contracts/id/{id}/edit
Authorization¶
This endpoint requires authentication. Use a Bearer token from an authenticated user.
Request Headers¶
Authorization: Bearer <your_token_here>
Accept: application/json
Content-Type: application/json
Request Body Structure¶
You may send a partial payload containing only the fields you wish to update. The public wrapper merges existing contract attributes with the incoming payload so required fields are not overwritten with null values. Common fields you can update include:
client_price,vendor_pricetype(e.g.hourly,fixed)contract_start,contract_end,is_infiniteallocation(numeric percent, e.g.75— do not send75%unless the server sanitizes it)max_hours,unitservice_code,work_scope,notice_periodclient_company_name/vendor_company_name(wrapper will resolve/create companies)selected_consultant(object to create/update/assign consultant)consult_skills(array of strings or comma-separated string)notes,client_contact,vendor_contact,client_purchase_order
Notes:
- When updating selected_consultant, include selected_consultant object (with id to update existing or name to create new). The API will attach the consultant to the contract.
- If you omit consult_skills while changing consultant info, the wrapper may preserve existing skills, but it's safe to include consult_skills (can be []).
Example JSON¶
{
"client_price":"150.00",
"notes":"Updated via public API"
}
Step 2: Edit the Contract (cURL examples)¶
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"client_price":"150.00","notes":"Updated via public API"}'
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"type":"hourly","client_price":"180.00","vendor_price":"120.00"}'
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"contract_start":"2026-03-01","contract_end":"2026-12-31"}'
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"is_infinite":true}'
Important: send numeric
allocation(e.g.75), not"75%"unless the server sanitizes it.
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"allocation":75,"unit":"day","max_hours":120}'
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"service_code":"SVC-77","work_scope":"Integration work","notice_period":"30 days"}'
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"client_company_name":"Acme Oy","vendor_company_name":"Provider AB"}'
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"selected_consultant":{"name":"Jane Doe","title":"Senior Dev"},"consult_skills":[]}'
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"selected_consultant":{"id":42},"consult_skills":["Laravel","Vue.js","PHP"]}'
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/CNTR-2026-0005/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"selected_consultant":{"id":42},"consult_skills":"Laravel, Vue.js, PHP"}'
curl -i -X POST "https://api.sbox2.peoplecloudpro.com/api/v1/contracts/id/26/edit" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"client_price":"175.00"}'
Step 3: Evaluate response¶
Successful responses are typically JSON messages such as {"message":"Contract updated successfully"} or a standard 2xx status. Possible responses:
| Status | Meaning | Description |
|---|---|---|
| 200 | OK | Contract updated successfully |
| 204 | No Content | Update succeeded without response body |
| 400 | Bad Request | Malformed request payload |
| 401 | Unauthorized | Missing/invalid Bearer token |
| 404 | Not Found | Contract not found |
| 422 | Validation error | Validation failed for one or more fields |
| 500 | Server error | Server-side error |
Notes¶
- Always include
-H "Accept: application/json"to avoid HTML redirects to login pages. - For
allocation, send a numeric value (e.g.75) — sending"75%"may cause SQL warnings or errors unless the server sanitizes input. - When creating/updating a consultant, include
consult_skillsor pass an empty array to avoid server-side errors if the update path expects an array. - The public wrapper attempts to preserve existing fields during partial updates (including consultant information) but supplying the fields you care about is the safest approach.
- If you hit a
500that referencesarray_filter()onconsult_skills, sendconsult_skills: []or ask me to patch the API to normalizeconsult_skillsautomatically.