> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.joincandidhealth.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.joincandidhealth.com/_mcp/server.

# Update

PUT https://pre-api.joincandidhealth.com/metadata-schemas/v1/{id}/{version}
Content-Type: application/json

Updates a custom metadata schema. Updates are additive only: new fields may be added but existing fields may not be removed or have their type changed, and ENUM field value lists may be extended but not shrunk. The path must contain the most recent version to prevent races.

Reference: https://docs.joincandidhealth.com/api-reference/pre-encounter/metadata-schemas/v-1/update

## Authentication

- OAuth2 — send the obtained token as `Authorization: Bearer <token>`

## Servers

- `https://pre-api.joincandidhealth.com` (Production, default)
- `https://pre-api-staging.joincandidhealth.com` (Staging)
- `https://sandbox-pre-api.joincandidhealth.com` (CandidSandbox)
- `https://staging-pre-api.joincandidhealth.com` (CandidStaging)
- `http://localhost:4000` (Local)

## Request

### Path parameters

- `id` (UUID, required) — The unique identifier for a custom MetadataSchema.
- `version` (string, required)

### Body (application/json)

This endpoint expects a MutableMetadataSchema.

- `name` (string, required)
- `fields` (list of MetadataField, required)
- `description` (string, optional)

## Response

### 200

- `deactivated` (boolean, required) — True if the object is deactivated. Deactivated objects are not returned in search results but are returned in all other endpoints including scan.
- `fields` (list of MetadataField, required)
- `id` (UUID, required) — The unique identifier for a custom MetadataSchema.
- `name` (string, required)
- `organization_id` (string, required) — The organization that owns this object.
- `updated_at` (datetime, required)
- `updating_user_id` (string, required) — The user ID of the user who last updated the object.
- `version` (integer, required) — The version of the object. Any update to any property of an object object will create a new version.
- `description` (string, optional)

## Types

### MetadataField

A single typed field within a custom metadata schema.

- `key` (string, required)
- `type` (enum, required) — The value type of a custom metadata field.
  - Allowed values: `STRING`, `INTEGER`, `DOUBLE`, `BOOLEAN`, `ENUM`
- `enum_values` (list of string, optional) — The allowed values for the field. Required when type is ENUM, otherwise omitted.

## Examples

**Request**

```json
{
  "name": "name",
  "fields": [
    {
      "key": "key",
      "type": "STRING"
    },
    {
      "key": "key",
      "type": "STRING"
    }
  ]
}
```

**Response**

```json
{
  "deactivated": true,
  "fields": [
    {
      "key": "key",
      "type": "STRING",
      "enum_values": [
        "enum_values",
        "enum_values"
      ]
    },
    {
      "key": "key",
      "type": "STRING",
      "enum_values": [
        "enum_values",
        "enum_values"
      ]
    }
  ],
  "id": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  "name": "name",
  "organization_id": "organization_id",
  "updated_at": "2024-01-15T09:30:00Z",
  "updating_user_id": "updating_user_id",
  "version": 1,
  "description": "description"
}
```

**SDK Code**

```python
import requests

url = "https://pre-api.joincandidhealth.com/metadata-schemas/v1/d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32/version"

payload = {
    "name": "name",
    "fields": [
        {
            "key": "key",
            "type": "STRING"
        },
        {
            "key": "key",
            "type": "STRING"
        }
    ]
}
headers = {
    "Authorization": "<token>.",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://pre-api.joincandidhealth.com/metadata-schemas/v1/d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32/version';
const options = {
  method: 'PUT',
  headers: {Authorization: '<token>.', 'Content-Type': 'application/json'},
  body: '{"name":"name","fields":[{"key":"key","type":"STRING"},{"key":"key","type":"STRING"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://pre-api.joincandidhealth.com/metadata-schemas/v1/d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32/version"

	payload := strings.NewReader("{\n  \"name\": \"name\",\n  \"fields\": [\n    {\n      \"key\": \"key\",\n      \"type\": \"STRING\"\n    },\n    {\n      \"key\": \"key\",\n      \"type\": \"STRING\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "<token>.")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://pre-api.joincandidhealth.com/metadata-schemas/v1/d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32/version")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = '<token>.'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"name\",\n  \"fields\": [\n    {\n      \"key\": \"key\",\n      \"type\": \"STRING\"\n    },\n    {\n      \"key\": \"key\",\n      \"type\": \"STRING\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://pre-api.joincandidhealth.com/metadata-schemas/v1/d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32/version")
  .header("Authorization", "<token>.")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"name\",\n  \"fields\": [\n    {\n      \"key\": \"key\",\n      \"type\": \"STRING\"\n    },\n    {\n      \"key\": \"key\",\n      \"type\": \"STRING\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://pre-api.joincandidhealth.com/metadata-schemas/v1/d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32/version', [
  'body' => '{
  "name": "name",
  "fields": [
    {
      "key": "key",
      "type": "STRING"
    },
    {
      "key": "key",
      "type": "STRING"
    }
  ]
}',
  'headers' => [
    'Authorization' => '<token>.',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://pre-api.joincandidhealth.com/metadata-schemas/v1/d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32/version");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "<token>.");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"name\",\n  \"fields\": [\n    {\n      \"key\": \"key\",\n      \"type\": \"STRING\"\n    },\n    {\n      \"key\": \"key\",\n      \"type\": \"STRING\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<token>.",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "name",
  "fields": [
    [
      "key": "key",
      "type": "STRING"
    ],
    [
      "key": "key",
      "type": "STRING"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://pre-api.joincandidhealth.com/metadata-schemas/v1/d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32/version")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```