# Update a person

`PATCH /v4/records/people/{id}`

Updates a record name and/or custom field values addressed by field slug. Requires `people:write`.

Send `name`, `custom_fields`, or both; for people also `gender`. `custom_fields` keys must match the field slug exposed on reads; JSON null clears a value. `gender` is `male`, `female`, `other`, or `""` to clear it; on any other record type it is 422 `UNKNOWN_FIELD`, and another value is 422 `INVALID_GENDER`.

Authentication (security requirement alternatives):

```json
[
  {
    "bearer_auth": [
      "people:write"
    ]
  },
  {
    "oauth2_auth": [
      "people:write"
    ]
  },
  {
    "apikey_auth": [
      "people:write"
    ]
  }
]
```

- bearer_auth: http (bearer). API key or OAuth access token in Authorization header; scopes: people:write
- oauth2_auth: oauth2. OAuth authorization code flow with mandatory S256 PKCE.; scopes: people:write
- apikey_auth: apiKey, query api_key. API key in query string; scopes: people:write

Parameters:

- `id` (path, string, required) - Person ID
  Type: string

Request body: application/json

Type: object

Schema: [UpdateRecordRequest](https://docs.searchsoftware.nl/api/models/updaterecordrequest.md)

- `name` (optional)
  Type: string
  
  New record name. For jobs this updates the title.
  
  Example:
  
  ```json
  "Jane Doe"
  ```

- `custom_fields` (optional)
  Type: object
  
  Custom field values keyed by field slug. JSON null clears the value; arrays and objects are accepted for multi-value fields.
  
  Additional properties: 
    Type: unknown

Responses:

- 200: Record updated

Content type: application/json

Type: object

Schema: [PersonResponse](https://docs.searchsoftware.nl/api/models/personresponse.md)

- `status` (required)
  Type: string
  
  enum: ["ok"]
  
  Example:
  
  ```json
  "ok"
  ```

- `data` (required)
  Reference: [PersonData](https://docs.searchsoftware.nl/api/models/persondata.md); Type: object

- 400: Invalid id or request body

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_BODY",
    "status_code": 400,
    "message": "Invalid request body"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_BODY",
    "status_code": 400,
    "message": "Invalid request body"
  }
}
```

- 401: Invalid API key

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

- 403: Insufficient scope

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "FORBIDDEN",
    "status_code": 403,
    "message": "Insufficient scope"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "FORBIDDEN",
    "status_code": 403,
    "message": "Insufficient scope"
  }
}
```

- 404: Record not found

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "NOT_FOUND",
    "status_code": 404,
    "message": "Record not found"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "NOT_FOUND",
    "status_code": 404,
    "message": "Record not found"
  }
}
```

- 422: No changes, invalid name, unknown field, or validation error

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "VALIDATION_FAILED",
    "status_code": 422,
    "message": "Validation failed"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "VALIDATION_FAILED",
    "status_code": 422,
    "message": "Validation failed"
  }
}
```

- 500: Internal server error

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INTERNAL_ERROR",
    "status_code": 500,
    "message": "Internal server error"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INTERNAL_ERROR",
    "status_code": 500,
    "message": "Internal server error"
  }
}
```

## Examples

### cURL

```bash
curl -X PATCH 'https://api.searchsoftware.nl/v4/records/people/string' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "name": "Jane Doe",
  "custom_fields": {}
}'
```

### TypeScript

```typescript
const body = `{
  "name": "Jane Doe",
  "custom_fields": {}
}`;

const response = await fetch('https://api.searchsoftware.nl/v4/records/people/string', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "name": "Jane Doe",
  "custom_fields": {}
}'''

response = requests.patch(
    'https://api.searchsoftware.nl/v4/records/people/string',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```

### Ruby

```ruby
require 'net/http'
require 'json'

uri = URI('https://api.searchsoftware.nl/v4/records/people/string')
request = Net::HTTP::Patch.new(uri)
request.body = <<-'BODY'.chomp
{
  "name": "Jane Doe",
  "custom_fields": {}
}
BODY
request['Authorization'] = 'Bearer YOUR_TOKEN'
request['Content-Type'] = 'application/json'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(request) }
data = JSON.parse(response.body)
```

### Go

```go
package main

import (
  "fmt"
  "io"
  "net/http"
  "strings"
)

func main() {
  body := strings.NewReader(`{
  "name": "Jane Doe",
  "custom_fields": {}
}`)
  req, _ := http.NewRequest("PATCH", "https://api.searchsoftware.nl/v4/records/people/string", body)
  req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
  req.Header.Set("Content-Type", "application/json")
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  data, _ := io.ReadAll(resp.Body)
  fmt.Println(string(data))
}
```

### PHP

```php
<?php
$body = <<<'BODY'
{
  "name": "Jane Doe",
  "custom_fields": {}
}
BODY;

$ch = curl_init('https://api.searchsoftware.nl/v4/records/people/string');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_TOKEN', 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

### Rust

```rust
use reqwest;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let client = reqwest::Client::new();
    let body = r#"{
  "name": "Jane Doe",
  "custom_fields": {}
}"#;
    let response = client.patch("https://api.searchsoftware.nl/v4/records/people/string")
        .body(body)
        .header("Authorization", "Bearer YOUR_TOKEN")
        .header("Content-Type", "application/json")
        .send()
        .await?
        .text()
        .await?;
    println!("{}", response);
    Ok(())
}
```
