# Set person types

`PUT /v4/records/people/{id}/types`

Replaces the record's types with `types`; an empty list clears them. Each entry is a prefixed type ID as the record's `types` attribute returns (`person_type:<sqid>`) or a type's `string_id`. Active types come from `GET /v4/records/{plural_slug}/types`. At most 50. Requires `people:write`.

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

- `types` (required)
  Type: array
  
  Type IDs or string_ids, such as ["person_type:Ab12", "candidate"]

Responses:

- 200: Types set

Content type: application/json

Type: object

Schema: [SetTypesResponse](https://docs.searchsoftware.nl/api/models/settypesresponse.md)

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

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

- 400: Invalid id or 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: Person 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: Unknown, archived or wrong-kind type, or more than 50

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 PUT 'https://api.searchsoftware.nl/v4/records/people/string/types' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "types": []
}'
```

### TypeScript

```typescript
const body = `{
  "types": []
}`;

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

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

### Python

```python
import requests

body = '''{
  "types": []
}'''

response = requests.put(
    'https://api.searchsoftware.nl/v4/records/people/string/types',
    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/types')
request = Net::HTTP::Put.new(uri)
request.body = <<-'BODY'.chomp
{
  "types": []
}
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(`{
  "types": []
}`)
  req, _ := http.NewRequest("PUT", "https://api.searchsoftware.nl/v4/records/people/string/types", 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'
{
  "types": []
}
BODY;

$ch = curl_init('https://api.searchsoftware.nl/v4/records/people/string/types');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
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#"{
  "types": []
}"#;
    let response = client.put("https://api.searchsoftware.nl/v4/records/people/string/types")
        .body(body)
        .header("Authorization", "Bearer YOUR_TOKEN")
        .header("Content-Type", "application/json")
        .send()
        .await?
        .text()
        .await?;
    println!("{}", response);
    Ok(())
}
```
