Update Corporate
This PUT endpoint is used to update an existing corporate record in the system. The request must include necessary corporate details, including company association and sub-company information.
Endpoint
- URL:
/api/corporates/:id - Method:
PUT
Authentication
- Header:
accessToken - Type: Bearer Token
- Value:
<ACCESS-TOKEN>
Request Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be application/json. |
accessToken | string | Access token for authentication. (required) |
Request Body
The body of the request should be a JSON object containing the following corporate details:
| Field | Type | Description | Required |
|---|---|---|---|
parentCompany | string | The ID of the parent company. | No |
name | string | The name of the corporate entity. | No |
active | boolean | Indicates if the corporate entity is active. | No |
subCompanies | array | Array of company IDs representing sub-companies. | No |
Sample Request Body
{
"parentCompany": "637e18fc741020de0693227a",
"name": "Axim Solutions",
"active": true,
"subCompanies": ["637e18fc741020de0693227b", "637e18fc741020de0693227c"]
}
Response
- Status Code: 200 OK
Success Response Body
{
"success": true,
"message": "Corporate updated successfully",
"data": {
"id": "generated_id_here"
// other corporate details...
}
}
Success Response Body Structure
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the request was successful. |
message | string | Message indicating the result of the operation. |
data | object | Contains details of the updated corporate. |
Data Object (data)
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the corporate entity. |
parentCompany | string | The ID of the parent company. |
name | string | The name of the corporate entity. |
active | boolean | Indicates if the corporate is active. |
subCompanies | array | List of associated sub-companies. |
createdAt | string | Timestamp of when the corporate was created. |
updatedAt | string | Timestamp of the last update to the corporate data. |
Error Responses
| Status Code | Description |
|---|---|
| 400 Bad Request | The request body contains invalid data or is missing required fields. |
| 401 Unauthorized | The access token is invalid or missing. |
| 404 Not Found | The corporate entity does not exist. |
| 500 Internal Server Error | An error occurred on the server. |
Notes
- Ensure that all required fields are included in the request body.
- Confirm that your access token is valid and has permissions to update corporate data.
- This endpoint updates an existing corporate entity and returns its updated details on success.