PATCH and PUT update rules, one rule for omitted, null and unknown fields
Use this page to read every record update the same way. PATCH means a partial update. PUT means a full replacement. One rule below covers omitted fields, explicit null values and unknown fields for both methods, so a client never needs a second guess for the same field.
How to read this page
Scope is limited to update endpoints for permit, workspace and user records. An endpoint not stated in this site pack is Unknown on this site. Unknown: PATCH and PUT endpoint list per resource not in supplied site pack. Unknown: field list per resource not in supplied site pack. Unknown: nullable field list per resource not in supplied site pack. Do not rely on a rule for a named field until the town office supplies that field list from the app modules outside this site pack. Where this page and a record differ, the record and the town document for that record govern.
- PUT replaces the whole record representation sent in the request. PATCH changes only the fields sent in the request.
- Every update is atomic. Where any field fails validation, no field is applied and the record stays as it was before the request.
- Every success and error body uses the envelope on the unified API response contract page. A success returns the updated record in data, with meta request_id and checked_at. An error returns ok false, error code and error message, with the same HTTP status as the code class.
- A response never returns a secret, key, token, vault item, card detail, connection string, internal address or build version.
- Method and resource checks run before field validation. An unsupported method on a known resource path returns 405, not 400 and not 404. An unknown resource identifier in the fixed workspace returns 404. Neither case applies any field.
The one rule for omitted, null and unknown fields
Work down the table in order. The same row applies to a permit record, a workspace record and a user record. Field names stay snake_case, as on the unified API response contract page.
| Case | PATCH, partial update | PUT, full replacement | Response |
|---|---|---|---|
| Omitted field, required | Keep the stored value. An omitted required field is not an error on PATCH. | Reject the request. The field is missing from a full replacement. | 400, error code VALIDATION_FAILED, message names the field in plain words. No field is applied. |
| Omitted field, optional | Keep the stored value, including a stored null where one exists. | Clear the field to null where the field is nullable, and reject the request where the field is not nullable. | 200 on success with data holding the updated record. 400 with VALIDATION_FAILED where a non nullable optional field is omitted on PUT. |
| Explicit null, nullable field | Clear the field to null. This is the only way to clear a field on PATCH. | Clear the field to null. This is the same result as an omitted nullable field on PUT. | 200 on success with data holding the updated record. |
| Explicit null, non nullable field | Reject the request. Null is not a value for that field. | Reject the request. Null is not a value for that field. | 400, error code VALIDATION_FAILED, message names the field and states that a value is needed. No field is applied. |
| Unknown field, name not in the field list for that resource | Reject the request. Do not ignore the field and do not store it. | Reject the request. Do not ignore the field and do not store it. | 400, error code VALIDATION_FAILED, message names the unknown field in plain words. No field is applied. |
| Known field, wrong type or failed business rule | Reject the request. | Reject the request. | 400 for a malformed value, 422 with CHECKLIST_INCOMPLETE where a business rule needs a listed item, as on the unified API response contract page. No field is applied. |
Unsupported methods and resource identification
Check the method and the resource identifier before any field in the table above. A known path with the wrong method is not a missing resource, and a missing resource is not a validation failure. Neither case creates, changes or deletes a record.
| Case | PATCH and PUT handling | Response |
|---|---|---|
| Unsupported method on a known resource path, such as GET, POST or DELETE sent to a PATCH or PUT update endpoint, or PATCH or PUT sent to a create-only endpoint | Reject the request before field validation. Do not apply any field, do not create a record and do not delete a record. The permitted methods for that endpoint are the methods the town office recorded for that resource. | 405, error code METHOD_NOT_ALLOWED, message states the method in plain words, and the Allow response header lists the permitted methods for that endpoint. No data is returned and no field is applied. |
| Resource identifier in the path is not found in the fixed workspace | Reject the request. Do not create a record from the request body and do not apply any field to another record. | 404 with the error envelope on the unified API response contract page, a plain sentence message, and no data. The message does not state whether a record exists in another workspace. |
| Identifier in the path and identifier in the payload name different records | Reject the request. The path identifier is the record to update. Do not update the record named in the payload and do not update the record named in the path. | 400, error code VALIDATION_FAILED, message names the identifier field in plain words. No field is applied. |
| Identifier format | Use the identifier format recorded for that resource. For a permit record that format is the business record_number, assigned once at submission and never reused, carried in the path and, where the payload carries it, with the same value. A client never parses a database identifier from record_number, and a database identifier where an endpoint states one is an opaque string. For any other resource, use the format in the field list the town office supplies for that resource. Unknown: identifier format per resource not in supplied site pack, where that list is not supplied. Do not invent a format from another resource, another record or an example. | 200 on success with data holding the updated record, where the identifier format matches the recorded format. |
Check an update in order
Work through these steps in order. Each step ends with what you should see when it worked.
Read the field list for that resource first
Confirm the field list, which fields are required, which fields are optional and which fields are nullable, from the app module for that resource. You should see one list for the resource before you send an update.
Send PATCH for a partial change and PUT only for a full replacement
Use PATCH where only some fields change, and include only the fields that change. Use PUT only where the client holds the full current representation and sends it back with the changes. Any other method on that endpoint returns 405 METHOD_NOT_ALLOWED with the Allow header, and no field is applied. You should see an omitted field on PATCH keep its stored value, and an omitted required field on PUT fail with VALIDATION_FAILED.
Confirm the resource identifier before you send
Send the identifier recorded for that resource in the path, and the same value in the payload where the payload carries it. You should see an unknown identifier return 404 with no data, and a mismatched identifier return 400 VALIDATION_FAILED with no field applied.
Send null only to clear a nullable field
Where a field must be cleared, send an explicit null for that field on PATCH or on PUT. Do not omit the field on PATCH to clear it, and do not send null for a non nullable field. You should see a cleared nullable field return null in data, and a null for a non nullable field fail with VALIDATION_FAILED and no field applied.
Fix an unknown field by removing it, not by renaming it silently
Where the response names an unknown field, remove that field from the request and send again with only field names from the field list. Do not rename the field to a similar name. You should see the second request succeed without the unknown field.
Read the updated record from data, not from the request
After a 200 response, read the record from data and confirm the fields that changed and the fields that stayed as they were. You should see the same record number, the same workspace, and the new values only where the request sent them.
- Workspace stays fixed on every update. An update never moves a record to another workspace, and a workspace name sent in the request does not change the workspace of the record.
- Sign-in, workspace and role checks from the API authorization page apply before this validation. A 401 or a 403 refusal returns no record field and no updated data.
- Where a field list, a nullable list or an endpoint name is not supplied, write Unknown for that item in setup notes and do not send an update for that field until the town office supplies the list.
Unified API response contract · API authorization rules · Query contract
Bring your field list to the demo
Tell us which record you need to update first, and we will confirm its field list, its nullable fields and its PATCH and PUT rule with your town role list.
Centralized request validation schema for create and update endpoints
Use one validation order for every create request and every update request for permit, workspace and user records and for related resources named in setup notes. Create means POST. Update means PATCH or PUT. The same field list, the same type, the same enum list, the same string length, the same numeric range and the same unknown-field rule apply to a field on create and on update, so a value accepted on create is not rejected on update for the same reason. Pass 0, method and resource identification, runs before pass 1 in the table below and uses the 405, 404 and identifier mismatch responses in the section above.
| Pass, in order | Create, POST | Update, PATCH | Update, PUT | Response where the pass fails |
|---|---|---|---|---|
| 1. Unknown fields | Reject any field name that is not in the field list for that resource. Do not ignore the field and do not store it. | Reject any field name that is not in the field list for that resource. | Reject any field name that is not in the field list for that resource. | 400, VALIDATION_FAILED, message names the unknown field. No record is created and no field is applied. |
| 2. Required fields | Reject where a required field is omitted or is an empty string after trimming where the field list states a non-empty value. | Keep the stored value where a required field is omitted. | Reject where a required field is omitted from the full replacement. | 400, VALIDATION_FAILED, message names each missing required field. No record is created and no field is applied. |
| 3. Explicit null and nullable | Reject null where the field is not nullable. Clear only where an optional record is created with a nullable field set to null in the field list. | Clear a nullable field only with an explicit null. Reject null where the field is not nullable. | Clear a nullable field with an explicit null or by omission. Reject null where the field is not nullable. | 400, VALIDATION_FAILED, message names the field and states that a value is needed where the field is not nullable. |
| 4. Type | The value must match the type in the field list, string, number, boolean, list, object or date string as stated for that field. Do not coerce a string to a number, a number to a string, or a date string to another type silently. | The same type rule as create for every field sent. | The same type rule as create for every field sent in the full replacement. | 400, VALIDATION_FAILED, message names the field and the type needed. No record is created and no field is applied. |
| 5. Enum values | The value must be one of the allowed values in the field list for that resource, in the stored form stated on the canonical taxonomy page. Reject a display form, a different case and a synonym that is not in the list. | The same enum list as create for every field sent. | The same enum list as create for every field sent in the full replacement. | 400, VALIDATION_FAILED, message names the field and that the value is not allowed. Do not list a value from another resource or another lane. |
| 6. String length, trim and pattern | Trim leading and trailing spaces where the field list states trimming. Reject a required string that is empty after trimming. Reject a string longer than the maximum length recorded for that field. Reject a code or identifier string that does not match the pattern recorded for that field. | The same trim, maximum length and pattern as create for every string field sent. An omitted field keeps its stored value and is not retrimmed by the request. | The same trim, maximum length and pattern as create for every string field in the full replacement. | 400, VALIDATION_FAILED, message names the field and states that the value is too long, empty where a value is needed, or does not match the pattern. No record is created and no field is applied. |
| 7. Numeric range | The value must be a finite number within the minimum and maximum recorded for that field. Reject a non-finite value, a value outside the range, and a decimal value where the field list states a whole number. | The same finite, range and whole-number rule as create for every numeric field sent. | The same finite, range and whole-number rule as create for every numeric field in the full replacement. | 400, VALIDATION_FAILED, message names the field and states that the value is outside the allowed range or is not a whole number where the list states a whole number. |
| 8. Business rule after type, enum, length and range pass | Where a business rule in the field list is not met, reject the request. A missing listed item uses 422 with CHECKLIST_INCOMPLETE where the unified API response contract page states it, as on the correction and filing checks. | The same business rule as create for the fields sent, applied atomically with the whole request. | The same business rule as create, applied to the full replacement. | 400 for a malformed value, 422 with CHECKLIST_INCOMPLETE where a listed item is missing. No record is created and no field is applied. |
- Atomic in every pass. Where any field fails any pass, no record is created and no field is applied, and the stored record stays as it was before the request.
- Sign-in, workspace and role checks apply before this validation. A 401 or a 403 refusal returns no record field and no created or updated data, as on the API authorization page.
- Workspace stays fixed on create and on update. A workspace name or identifier sent in the request does not create or move a record to another workspace.
- Field names stay snake_case on create and on update, as on the unified API response contract page. Do not rename a field to a similar name to pass a pass.
Schema to record for each resource before live use
Record one row per field in setup notes for each resource named there, permit, workspace, user and each related resource. Do not publish a length, range, pattern or enum list that is not in that recorded row.
| Item to record | What to enter, same wording on create and update |
|---|---|
| Endpoint and method | Endpoint name, method POST for create, PATCH or PUT for update, and the resource it creates or updates. Unknown: endpoint list per resource not in supplied site pack, where the app module does not name it. |
| Field name | snake_case field name as in the field list for that resource. One name per field on create and on update. |
| Required and nullable | Required or optional, nullable or not nullable, stated once for the field and used on POST, PATCH and PUT in the table above. |
| Type | Type stated for the field, string, number, boolean, list, object or date string. A date string uses the format stated for that field in the field list. |
| Enum list | Allowed values in stored form where the field is an enum, as on the canonical taxonomy page. Blank where the field is not an enum. |
| String maximum length, trim and pattern | Maximum length recorded for that field, whether leading and trailing spaces are trimmed, and the pattern where the field is a code or identifier. The same three values apply on create and on update. |
| Numeric minimum, maximum and whole-number rule | Minimum and maximum recorded for that field, and whether a whole number is required. The same three values apply on create and on update. |
- Unknown: field list per resource not in supplied site pack. Unknown: maximum length per field not in supplied site pack. Unknown: numeric range per field not in supplied site pack. Unknown: pattern per code field not in supplied site pack. Record each answer in setup notes with the town office before live use and do not rely on a field until its row is recorded.
- Where a field is not in the recorded row for a resource, treat it as unknown on create and on update and reject it under pass 1.
- Keep the response truncation and support code rules already stated for the public form in the API delta report. Do not copy a public form truncation value to a signed-in record field.
Test create and update validation on a test record
Send an unknown field on create and on update
Send POST with one field name not in the recorded row, then send PATCH and PUT with the same unknown name on a test record. You should see 400 with VALIDATION_FAILED, the unknown field named, and no record created and no field applied in each case.
Send an unsupported method and an unknown or mismatched identifier
Send GET, POST and DELETE to the update endpoint, PATCH to the create endpoint, an unknown identifier in the path, and a path and payload identifier that do not match. You should see 405 METHOD_NOT_ALLOWED with the Allow header for each unsupported method, 404 with no data for the unknown identifier, and 400 VALIDATION_FAILED naming the identifier for the mismatch, with no field applied in every case.
Omit a required field on create and on PUT, and omit it on PATCH
Omit the same required field in each of the three requests. You should see create and PUT reject with VALIDATION_FAILED and PATCH keep the stored value with no other change.
Send a wrong type, a value outside an enum, an overlong string and an out of range number
Send each case on create and on update for the same field. You should see the same pass fail on create and on update, the field named, and no record created and no field applied where any case is sent with a valid field in the same request.
Send null for a nullable field and for a non nullable field
Send an explicit null for a nullable field and for a non nullable field on PATCH, then repeat on PUT. You should see the nullable field cleared to null in data and the non nullable field rejected with VALIDATION_FAILED and no field applied.
Confirm the stored record after each failure
Reopen the test record after each failed request. You should see the same record number, the same workspace, and the stored values unchanged, with no created record for a failed create.
Publish only after every pass passes on create and on update
Run the safe defaults health check in the setup guide, then publish only after the test passes. See Unified API response contract, API authorization rules and Canonical taxonomy.
Unified API response contract · API authorization rules · Canonical taxonomy · Query contract