> 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 custom schema

PATCH https://api.joincandidhealth.com/api/custom-schemas/v1/{schema_id}
Content-Type: application/json

Update the name, description, or keys on a preexisting schema.

Reference: https://docs.joincandidhealth.com/api-reference/custom-schemas/v-1/update

## Authentication

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

## Servers

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

## Request

### Path parameters

- `schema_id` (UUID, required)

### Body (application/json)

This endpoint expects an object.

- `name` (string, optional)
- `description` (string, optional)
- `fields_to_add` (list of SchemaField, optional) — A list of typed entries to add to schema. Only additive modifications are permitted.

## Response

### 200

- `id` (UUID, required)
- `name` (string, required)
- `fields` (list of SchemaField, required)
- `description` (string, optional)

## Errors

### 404 Entity Not Found Error

- `errorName` ("EntityNotFoundError", required)
- `content` (EntityNotFoundErrorMessage, required)

### 403 Unauthorized Error

- `errorName` ("UnauthorizedError", required)
- `content` (UnauthorizedErrorMessage, required)

### 422 Schema Validation HTTP Failure

- `errorName` ("SchemaValidationHttpFailure", required)
- `content` (SchemaValidationFailure, required)

## Types

### SchemaField

- `key` (string, required)
- `type` (enum, required) — The BOOLEAN and STRING primitives respectively map to the `boolean` and `string` JSON data types. The DOUBLE and INTEGER primitives must be written as a JSON `number` type.
  - Allowed values: `BOOLEAN`, `DOUBLE`, `INTEGER`, `STRING`

### EntityNotFoundErrorMessage

- `id` (string, required)

### UnauthorizedErrorMessage

- `message` (string, optional)

### SchemaValidationFailure

- `errors` (list of SchemaValidationError, required)

### SchemaValidationError

- `type`: `schema_name_already_exists`
  - `id` (UUID, required)
  - `name` (string, required)
- `type`: `key_name_already_exists`
  - `key` (string, required)
  - `value_type` (enum, required) — The BOOLEAN and STRING primitives respectively map to the `boolean` and `string` JSON data types. The DOUBLE and INTEGER primitives must be written as a JSON `number` type.
    - Allowed values: `BOOLEAN`, `DOUBLE`, `INTEGER`, `STRING`

## Examples

**Request**

```json
{
  "name": "General Medicine and Health",
  "description": "Values collected during all visits",
  "fields_to_add": [
    {
      "key": "visit_type",
      "type": "STRING"
    }
  ]
}
```

**Response**

```json
{
  "id": "ec096b13-f80a-471d-aaeb-54b021c9d582",
  "name": "General Medicine and Health",
  "fields": [
    {
      "key": "provider_category",
      "type": "STRING"
    },
    {
      "key": "is_urgent_care",
      "type": "BOOLEAN"
    },
    {
      "key": "bmi",
      "type": "DOUBLE"
    },
    {
      "key": "age",
      "type": "INTEGER"
    },
    {
      "key": "visit_type",
      "type": "STRING"
    }
  ],
  "description": "Values collected during all visits"
}
```

**SDK Code**

```python
import requests

url = "https://api.joincandidhealth.com/api/custom-schemas/v1/ec096b13-f80a-471d-aaeb-54b021c9d582"

payload = {
    "name": "General Medicine and Health",
    "description": "Values collected during all visits",
    "fields_to_add": [
        {
            "key": "visit_type",
            "type": "STRING"
        }
    ]
}
headers = {
    "Authorization": "<token>.",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.joincandidhealth.com/api/custom-schemas/v1/ec096b13-f80a-471d-aaeb-54b021c9d582';
const options = {
  method: 'PATCH',
  headers: {Authorization: '<token>.', 'Content-Type': 'application/json'},
  body: '{"name":"General Medicine and Health","description":"Values collected during all visits","fields_to_add":[{"key":"visit_type","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://api.joincandidhealth.com/api/custom-schemas/v1/ec096b13-f80a-471d-aaeb-54b021c9d582"

	payload := strings.NewReader("{\n  \"name\": \"General Medicine and Health\",\n  \"description\": \"Values collected during all visits\",\n  \"fields_to_add\": [\n    {\n      \"key\": \"visit_type\",\n      \"type\": \"STRING\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("PATCH", 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://api.joincandidhealth.com/api/custom-schemas/v1/ec096b13-f80a-471d-aaeb-54b021c9d582")

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

request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<token>.'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"General Medicine and Health\",\n  \"description\": \"Values collected during all visits\",\n  \"fields_to_add\": [\n    {\n      \"key\": \"visit_type\",\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.patch("https://api.joincandidhealth.com/api/custom-schemas/v1/ec096b13-f80a-471d-aaeb-54b021c9d582")
  .header("Authorization", "<token>.")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"General Medicine and Health\",\n  \"description\": \"Values collected during all visits\",\n  \"fields_to_add\": [\n    {\n      \"key\": \"visit_type\",\n      \"type\": \"STRING\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.joincandidhealth.com/api/custom-schemas/v1/ec096b13-f80a-471d-aaeb-54b021c9d582', [
  'body' => '{
  "name": "General Medicine and Health",
  "description": "Values collected during all visits",
  "fields_to_add": [
    {
      "key": "visit_type",
      "type": "STRING"
    }
  ]
}',
  'headers' => [
    'Authorization' => '<token>.',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.joincandidhealth.com/api/custom-schemas/v1/ec096b13-f80a-471d-aaeb-54b021c9d582");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "<token>.");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"General Medicine and Health\",\n  \"description\": \"Values collected during all visits\",\n  \"fields_to_add\": [\n    {\n      \"key\": \"visit_type\",\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": "General Medicine and Health",
  "description": "Values collected during all visits",
  "fields_to_add": [
    [
      "key": "visit_type",
      "type": "STRING"
    ]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.joincandidhealth.com/api/custom-schemas/v1/ec096b13-f80a-471d-aaeb-54b021c9d582")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```