Update Organization
Method
REST method is adopted.
HTTP Method
PUT: Update organization information
Naming Convention
To unify the naming of query parameters and nodes and improve readability, snake_case is used for URIs and JSON nodes in requests.
Request and Response
Headers
Meta information is set in HTTP headers, not in the response body.
Request Headers
AuthorizationContent-TypeAcceptAccept-language
Response Headers
Content-Type
Update Organization Information
URI
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| organization_id | string | Required | Organization UUID |
Request Body
The request body is JSON.
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Required | Organization name (1-255 characters) |
Response
The response is JSON.
{
"id": "org-uuid",
"name": "Updated Organization Name",
"createdAt": 1234567890000,
"updatedAt": 1234567899999,
"createdBy": "creator-id",
"updatedBy": "updater-id",
"deletedAt": null,
"deletedBy": null
}
Response Fields
| Name | Type | Description |
|---|---|---|
| id | string | Organization UUID |
| name | string | Organization name |
| createdAt | number | Creation timestamp (epoch milliseconds) |
| updatedAt | number | Update timestamp (epoch milliseconds) |
| deletedAt | number | null | Deletion timestamp (epoch milliseconds) |
Authentication
Authentication is performed using JSON Web Tokens (JWT) issued by Amazon Cognito.
Error Handling
The status codes for error handling are as follows.
| Description | Status Code | Status Name |
|---|---|---|
| Invalid name (empty, too long, etc.) | 400 | Bad Request |
| Missing credentials | 401 | Unauthorized |
| Insufficient permissions | 403 | Forbidden |
| Organization not found | 404 | Not Found |
| Internal server error | 500 | Internal Server Error |
Processing Flow
- Extract organization ID from path parameters
- Extract name from request body
- Retrieve the requester's Cognito sub
- Perform admin/user access check in the service handler
- Verify the requester is a member of the organization
- Update the organization in the database
- Return updated organization information
Detailed Flowchart
flowchart TD
Start([PUT Request]) --> Route[Route Handler]
Route --> Auth[Auth & Parameter Extraction]
Auth --> Service[Service Layer]
Service --> CheckOrg{Organization exists?}
CheckOrg -->|No| Err404[404 Not Found]
CheckOrg -->|Yes| AccessCheck[Access Check]
AccessCheck --> IsAdmin{Admin?}
IsAdmin -->|Yes| ValidateName
IsAdmin -->|No| CheckUser{User?}
CheckUser -->|No| Err404
CheckUser -->|Yes| CheckOrgMatch{Organization match?}
CheckOrgMatch -->|No| Err404
CheckOrgMatch -->|Yes| ValidateName
ValidateName{name validation<br/>1-255 chars} -->|NG| Err400[400 Bad Request]
ValidateName -->|OK| UpdateDB
UpdateDB[DB Update<br/>Transaction] --> SetName[Update name]
SetName --> SetUpdatedAt[Set updatedAt, updatedBy]
SetUpdatedAt --> Refetch[Fetch updated record]
Refetch --> Commit[Commit]
Commit --> Success[200 OK]
Validation
- Name is required
- Minimum name length: 1 character
- Maximum name length: 255 characters
- Whitespace-only names are not allowed
- Leading and trailing whitespace is automatically trimmed