> For the complete documentation index, see [llms.txt](https://docs.welkinhealth.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.welkinhealth.com/api-reference/cdt-record.md).

# CDT Record

CDT records in Welkin are associated with a Patient. In REST terms, they are a sub-resource to the patient object

Each CDT record has a set of system fields associated with it and a set of custom fields that you will create in the designer.

### Formula field type

Type *formula* is intended for calculating values at the time of receipt of the cdt record. The *formula* looks like a mathematical expression. See **Example 1**.

> Example 1 of a simple formula

```
{
  "formula": "(2 + 2) * 2"
}

```

***Variables***

The formula supports the mechanism of variables. This allows you to reference fields in CDT and substitute values into the formula at runtime. To refer to a field, you should specify the field name and enclose it in double curly brackets. An example of a field reference is *{{some-cdt-field}}*. See **Example 2**.

**Example**

Some *cdt* contains two *integer* fields named *field-a* and *field-b*. The formula for calculating the sum of these fields values is as follows.

> Example 2 of a sum of fields values

```
{
  "formula": "{{field-a}} + {{field-b}}"
}

```

***Functions***

The formula supports the mechanism of functions. Functions allow you to perform more complex calculations. to specify a function, you should specify **#** and then the **name** of the function and parentheses **()** to list the passed parameters. An example of a function is *#functionName(2, {{variable}})*

**Example**

You want to know how many days have passed since the onset of the illness. A cdt contains a *date* field named *onset-disease*. See **Example 3**.

## Get all CDT Records

> Get all cdt records\
> \
> 1\.  HTTP Request\
> &#x20;   \
> \
> \*\*\*GET\*\*\* \`/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}\`\
> \
> 2\\. In our example it would be:\
> \
> \*\*\*GET\*\*\* \`<https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals\\`\\>
> \
> \*\*Responses\*\*\
> \
> \| Code | Description |\
> \| --- | --- |\
> \| 200 | OK |\
> \| 401 | Unauthorized |\
> \| 403 | Forbidden |\
> \| 404 | Not Found |

````json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"CDT Record","description":"CDT records in Welkin are associated with a Patient. In REST terms, they are a sub-resource to the patient object\n\nEach CDT record has a set of system fields associated with it and a set of custom fields that you will create in the designer.\n\n## Formula field type\n\nType *formula* is intended for calculating values at the time of receipt of the cdt record. The *formula* looks like a mathematical expression. See **Example 1**.\n\n> Example 1 of a simple formula\n\n```\n{\n  \"formula\": \"(2 + 2) * 2\"\n}\n\n```\n\n***Variables***\n\nThe formula supports the mechanism of variables. This allows you to reference fields in CDT and substitute values into the formula at runtime. To refer to a field, you should specify the field name and enclose it in double curly brackets. An example of a field reference is *{{some-cdt-field}}*. See **Example 2**.\n\n**Example**\n\nSome *cdt* contains two *integer* fields named *field-a* and *field-b*. The formula for calculating the sum of these fields values is as follows.\n\n> Example 2 of a sum of fields values\n\n```\n{\n  \"formula\": \"{{field-a}} + {{field-b}}\"\n}\n\n```\n\n***Functions***\n\nThe formula supports the mechanism of functions. Functions allow you to perform more complex calculations. to specify a function, you should specify **#** and then the **name** of the function and parentheses **()** to list the passed parameters. An example of a function is *#functionName(2, {{variable}})*\n\n**Example**\n\nYou want to know how many days have passed since the onset of the illness. A cdt contains a *date* field named *onset-disease*. See **Example 3**."}],"servers":[{"url":"https://api.live.welkincloud.io","description":"Welkin Health production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Bearer token obtained from `POST /{tenantName}/admin/api_clients/{clientName}`. Valid for 60 minutes."}},"parameters":{"TenantName":{"name":"tenantName","in":"path","required":true,"description":"Your organization (tenant) name, e.g. `acme-health`","schema":{"type":"string"}},"InstanceName":{"name":"instanceName","in":"path","required":true,"description":"Your environment name: `live`, `sandbox`, or a custom name","schema":{"type":"string"}},"PatientId":{"name":"patientId","in":"path","required":true,"description":"UUID of the patient record","schema":{"type":"string","format":"uuid"}},"CdtName":{"name":"cdtName","in":"path","required":true,"description":"Machine-readable CDT name defined in Designer (e.g. `my_custom_type`)","schema":{"type":"string"}}},"schemas":{"CdtRecordList":{"type":"object","properties":{"name":{"type":"string"},"data":{"allOf":[{"$ref":"#/components/schemas/PaginatedResponse"},{"type":"object","properties":{"content":{"type":"array","items":{"$ref":"#/components/schemas/CdtRecord"}}}}]}}},"PaginatedResponse":{"type":"object","description":"Standard paginated response wrapper.","properties":{"content":{"type":"array","items":{"type":"object"}},"pageable":{"$ref":"#/components/schemas/PageableInfo"},"totalElements":{"type":"integer","description":"Total number of matching records"},"totalPages":{"type":"integer","description":"Total number of pages"},"last":{"type":"boolean"},"first":{"type":"boolean"},"number":{"type":"integer","description":"Current page number (zero-based)"},"size":{"type":"integer","description":"Page size"},"numberOfElements":{"type":"integer","description":"Number of elements on the current page"},"empty":{"type":"boolean"},"sort":{"$ref":"#/components/schemas/SortInfo"}}},"PageableInfo":{"type":"object","properties":{"sort":{"$ref":"#/components/schemas/SortInfo"},"pageSize":{"type":"integer"},"pageNumber":{"type":"integer"},"offset":{"type":"integer"},"unpaged":{"type":"boolean"},"paged":{"type":"boolean"}}},"SortInfo":{"type":"object","properties":{"sorted":{"type":"boolean"},"unsorted":{"type":"boolean"},"empty":{"type":"boolean"}}},"CdtRecord":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"patientId":{"type":"string","format":"uuid"},"cdtId":{"type":"string","format":"uuid"},"version":{"type":"integer"},"cdtName":{"type":"string"},"jsonBody":{"type":"object","additionalProperties":true,"description":"Fields defined by the CDT schema, plus system fields (id, created_at, created_by, etc)."}}}},"responses":{"BadRequest":{"description":"Bad request — the request could not be understood or was missing required parameters."},"Unauthorized":{"description":"Unauthorized — the Bearer token is missing, expired, or invalid."},"Forbidden":{"description":"Forbidden — the API client role does not have permission for this resource. Check the role and security policy in Admin."},"NotFound":{"description":"Not found — the requested resource does not exist."},"TooManyRequests":{"description":"Too many requests — rate limit exceeded. Implement exponential backoff."},"InternalError":{"description":"Internal server error."}}},"paths":{"/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}":{"get":{"summary":"Get all CDT Records","tags":["CDT Record"],"operationId":"Get_all_CDT_Records","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/CdtName"},{"name":"fields","in":"query","required":false,"schema":{"type":"string"},"description":": fields=name,phone"},{"name":"page","in":"query","required":false,"schema":{"type":"integer","default":0,"minimum":0},"description":"Page number"},{"name":"size","in":"query","required":false,"schema":{"type":"integer","default":20},"description":"Page size"},{"name":"filters","in":"query","required":false,"schema":{"type":"string"},"description":"key - cdt field name; v1,v3,v4 - values to search"},{"name":"dateStart","in":"query","required":false,"schema":{"type":"string","format":"date-time"},"description":"Date_time in ISO-8601 format"},{"name":"sort","in":"query","required":false,"schema":{"type":"string"},"description":"Sort field with sorting order(asc or desc) after coma"},{"name":"dateEnd","in":"query","required":false,"schema":{"type":"string","format":"date-time"},"description":"Date_time in ISO-8601 format"}],"responses":{"200":{"description":"Paginated CDT records","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdtRecordList"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalError"}},"description":"Get all cdt records\n\n1.  HTTP Request\n    \n\n***GET*** `/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}`\n\n2\\. In our example it would be:\n\n***GET*** `https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals`\n\n**Responses**\n\n| Code | Description |\n| --- | --- |\n| 200 | OK |\n| 401 | Unauthorized |\n| 403 | Forbidden |\n| 404 | Not Found |"}}}}
````

## Create CDT Record

> Create cdt record\
> \
> 1\.  HTTP Request\
> &#x20;   \
> \
> \*\*\*POST\*\*\* \`/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}\`\
> \
> 2\\. In our example it would be:\
> \
> \*\*\*POST\*\*\* \`<https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/{cdtName}\\`\\>
> \
> \*\*Responses\*\*\
> \
> \| Code | Description |\
> \| --- | --- |\
> \| 201 | Created |\
> \| 401 | Unauthorized |\
> \| 403 | Forbidden |\
> \| 404 | Not Found |

````json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"CDT Record","description":"CDT records in Welkin are associated with a Patient. In REST terms, they are a sub-resource to the patient object\n\nEach CDT record has a set of system fields associated with it and a set of custom fields that you will create in the designer.\n\n## Formula field type\n\nType *formula* is intended for calculating values at the time of receipt of the cdt record. The *formula* looks like a mathematical expression. See **Example 1**.\n\n> Example 1 of a simple formula\n\n```\n{\n  \"formula\": \"(2 + 2) * 2\"\n}\n\n```\n\n***Variables***\n\nThe formula supports the mechanism of variables. This allows you to reference fields in CDT and substitute values into the formula at runtime. To refer to a field, you should specify the field name and enclose it in double curly brackets. An example of a field reference is *{{some-cdt-field}}*. See **Example 2**.\n\n**Example**\n\nSome *cdt* contains two *integer* fields named *field-a* and *field-b*. The formula for calculating the sum of these fields values is as follows.\n\n> Example 2 of a sum of fields values\n\n```\n{\n  \"formula\": \"{{field-a}} + {{field-b}}\"\n}\n\n```\n\n***Functions***\n\nThe formula supports the mechanism of functions. Functions allow you to perform more complex calculations. to specify a function, you should specify **#** and then the **name** of the function and parentheses **()** to list the passed parameters. An example of a function is *#functionName(2, {{variable}})*\n\n**Example**\n\nYou want to know how many days have passed since the onset of the illness. A cdt contains a *date* field named *onset-disease*. See **Example 3**."}],"servers":[{"url":"https://api.live.welkincloud.io","description":"Welkin Health production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Bearer token obtained from `POST /{tenantName}/admin/api_clients/{clientName}`. Valid for 60 minutes."}},"parameters":{"TenantName":{"name":"tenantName","in":"path","required":true,"description":"Your organization (tenant) name, e.g. `acme-health`","schema":{"type":"string"}},"InstanceName":{"name":"instanceName","in":"path","required":true,"description":"Your environment name: `live`, `sandbox`, or a custom name","schema":{"type":"string"}},"PatientId":{"name":"patientId","in":"path","required":true,"description":"UUID of the patient record","schema":{"type":"string","format":"uuid"}},"CdtName":{"name":"cdtName","in":"path","required":true,"description":"Machine-readable CDT name defined in Designer (e.g. `my_custom_type`)","schema":{"type":"string"}}},"schemas":{"CdtRecord":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"patientId":{"type":"string","format":"uuid"},"cdtId":{"type":"string","format":"uuid"},"version":{"type":"integer"},"cdtName":{"type":"string"},"jsonBody":{"type":"object","additionalProperties":true,"description":"Fields defined by the CDT schema, plus system fields (id, created_at, created_by, etc)."}}}},"responses":{"BadRequest":{"description":"Bad request — the request could not be understood or was missing required parameters."},"Unauthorized":{"description":"Unauthorized — the Bearer token is missing, expired, or invalid."},"Forbidden":{"description":"Forbidden — the API client role does not have permission for this resource. Check the role and security policy in Admin."},"NotFound":{"description":"Not found — the requested resource does not exist."},"TooManyRequests":{"description":"Too many requests — rate limit exceeded. Implement exponential backoff."},"InternalError":{"description":"Internal server error."}}},"paths":{"/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}":{"post":{"summary":"Create CDT Record","tags":["CDT Record"],"operationId":"Create_CDT_Record","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/CdtName"}],"responses":{"201":{"description":"Created CDT record","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdtRecord"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalError"}},"description":"Create cdt record\n\n1.  HTTP Request\n    \n\n***POST*** `/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}`\n\n2\\. In our example it would be:\n\n***POST*** `https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/{cdtName}`\n\n**Responses**\n\n| Code | Description |\n| --- | --- |\n| 201 | Created |\n| 401 | Unauthorized |\n| 403 | Forbidden |\n| 404 | Not Found |","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"description":"Field values as defined by the target CDT schema."}}}}}}}}
````

## Update CDT Records with bulk

> Update cdt records with bulk. Allowed only for list fields with bulk edit flag\
> \
> 1\.  HTTP Request\
> &#x20;   \
> \
> \*\*\*PATCH\*\*\* \`/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}\`\
> \
> 2\\. In our example it would be:\
> \
> \*\*\*PATCH\*\*\* \`<https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals\\`\\>
> \
> \*\*Responses\*\*\
> \
> \| Code | Description |\
> \| --- | --- |\
> \| 200 | OK |\
> \| 401 | Unauthorized |\
> \| 403 | Forbidden |\
> \| 404 | Not Found |

````json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"CDT Record","description":"CDT records in Welkin are associated with a Patient. In REST terms, they are a sub-resource to the patient object\n\nEach CDT record has a set of system fields associated with it and a set of custom fields that you will create in the designer.\n\n## Formula field type\n\nType *formula* is intended for calculating values at the time of receipt of the cdt record. The *formula* looks like a mathematical expression. See **Example 1**.\n\n> Example 1 of a simple formula\n\n```\n{\n  \"formula\": \"(2 + 2) * 2\"\n}\n\n```\n\n***Variables***\n\nThe formula supports the mechanism of variables. This allows you to reference fields in CDT and substitute values into the formula at runtime. To refer to a field, you should specify the field name and enclose it in double curly brackets. An example of a field reference is *{{some-cdt-field}}*. See **Example 2**.\n\n**Example**\n\nSome *cdt* contains two *integer* fields named *field-a* and *field-b*. The formula for calculating the sum of these fields values is as follows.\n\n> Example 2 of a sum of fields values\n\n```\n{\n  \"formula\": \"{{field-a}} + {{field-b}}\"\n}\n\n```\n\n***Functions***\n\nThe formula supports the mechanism of functions. Functions allow you to perform more complex calculations. to specify a function, you should specify **#** and then the **name** of the function and parentheses **()** to list the passed parameters. An example of a function is *#functionName(2, {{variable}})*\n\n**Example**\n\nYou want to know how many days have passed since the onset of the illness. A cdt contains a *date* field named *onset-disease*. See **Example 3**."}],"servers":[{"url":"https://api.live.welkincloud.io","description":"Welkin Health production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Bearer token obtained from `POST /{tenantName}/admin/api_clients/{clientName}`. Valid for 60 minutes."}},"parameters":{"TenantName":{"name":"tenantName","in":"path","required":true,"description":"Your organization (tenant) name, e.g. `acme-health`","schema":{"type":"string"}},"InstanceName":{"name":"instanceName","in":"path","required":true,"description":"Your environment name: `live`, `sandbox`, or a custom name","schema":{"type":"string"}},"PatientId":{"name":"patientId","in":"path","required":true,"description":"UUID of the patient record","schema":{"type":"string","format":"uuid"}},"CdtName":{"name":"cdtName","in":"path","required":true,"description":"Machine-readable CDT name defined in Designer (e.g. `my_custom_type`)","schema":{"type":"string"}}},"schemas":{"BulkUpdateRequest":{"type":"object","properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/BulkUpdateRow"}}}},"BulkUpdateRow":{"type":"object","required":["id"],"properties":{"id":{"type":"string","format":"uuid","description":"UUID of the record to update"},"jsonBody":{"type":"object","description":"Fields to update. Keys are CDT field names.","additionalProperties":true},"result":{"type":"object","readOnly":true,"properties":{"status":{"type":"string","enum":["OK","ERROR"]},"content":{"type":"object","additionalProperties":true}}}}}},"responses":{"BadRequest":{"description":"Bad request — the request could not be understood or was missing required parameters."},"Unauthorized":{"description":"Unauthorized — the Bearer token is missing, expired, or invalid."},"Forbidden":{"description":"Forbidden — the API client role does not have permission for this resource. Check the role and security policy in Admin."},"NotFound":{"description":"Not found — the requested resource does not exist."},"TooManyRequests":{"description":"Too many requests — rate limit exceeded. Implement exponential backoff."},"InternalError":{"description":"Internal server error."}}},"paths":{"/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}":{"patch":{"summary":"Update CDT Records with bulk","tags":["CDT Record"],"operationId":"Update_CDT_Records_with_bulk","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/CdtName"}],"responses":{"200":{"description":"Bulk update result (per-row status)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkUpdateRequest"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalError"}},"description":"Update cdt records with bulk. Allowed only for list fields with bulk edit flag\n\n1.  HTTP Request\n    \n\n***PATCH*** `/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}`\n\n2\\. In our example it would be:\n\n***PATCH*** `https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals`\n\n**Responses**\n\n| Code | Description |\n| --- | --- |\n| 200 | OK |\n| 401 | Unauthorized |\n| 403 | Forbidden |\n| 404 | Not Found |","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkUpdateRequest"}}}}}}}}
````

## Get CDT Record By ID

> Get cdt record by identifier (id, external\_id, external\_guid)\
> \
> 1\.  HTTP Request\
> &#x20;   \
> \
> \*\*\*GET\*\*\* \`/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}/{cdtRecordId}\`\
> \
> 2\\. In our example it would be:\
> \
> \*\*\*GET\*\*\* \`<https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512\\`\\>
> \
> \*\*Responses\*\*\
> \
> \| Code | Description |\
> \| --- | --- |\
> \| 200 | OK |\
> \| 401 | Unauthorized |\
> \| 403 | Forbidden |\
> \| 404 | Not Found |\
> \
> \*\*Examples\*\*\
> \
> 1\.  \[<https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512]\\(https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512)\\>
> 2\.  \[<https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/4a245aac-217e-45f4-8727-5587220dd512?type=EGUID]\\(https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/4a245aac-217e-45f4-8727-5587220dd512?type=EGUID)\\>
> 3\.  \[<https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/externalId?type=EID]\\(https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/externalId?type=EID)>

````json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"CDT Record","description":"CDT records in Welkin are associated with a Patient. In REST terms, they are a sub-resource to the patient object\n\nEach CDT record has a set of system fields associated with it and a set of custom fields that you will create in the designer.\n\n## Formula field type\n\nType *formula* is intended for calculating values at the time of receipt of the cdt record. The *formula* looks like a mathematical expression. See **Example 1**.\n\n> Example 1 of a simple formula\n\n```\n{\n  \"formula\": \"(2 + 2) * 2\"\n}\n\n```\n\n***Variables***\n\nThe formula supports the mechanism of variables. This allows you to reference fields in CDT and substitute values into the formula at runtime. To refer to a field, you should specify the field name and enclose it in double curly brackets. An example of a field reference is *{{some-cdt-field}}*. See **Example 2**.\n\n**Example**\n\nSome *cdt* contains two *integer* fields named *field-a* and *field-b*. The formula for calculating the sum of these fields values is as follows.\n\n> Example 2 of a sum of fields values\n\n```\n{\n  \"formula\": \"{{field-a}} + {{field-b}}\"\n}\n\n```\n\n***Functions***\n\nThe formula supports the mechanism of functions. Functions allow you to perform more complex calculations. to specify a function, you should specify **#** and then the **name** of the function and parentheses **()** to list the passed parameters. An example of a function is *#functionName(2, {{variable}})*\n\n**Example**\n\nYou want to know how many days have passed since the onset of the illness. A cdt contains a *date* field named *onset-disease*. See **Example 3**."}],"servers":[{"url":"https://api.live.welkincloud.io","description":"Welkin Health production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Bearer token obtained from `POST /{tenantName}/admin/api_clients/{clientName}`. Valid for 60 minutes."}},"parameters":{"TenantName":{"name":"tenantName","in":"path","required":true,"description":"Your organization (tenant) name, e.g. `acme-health`","schema":{"type":"string"}},"InstanceName":{"name":"instanceName","in":"path","required":true,"description":"Your environment name: `live`, `sandbox`, or a custom name","schema":{"type":"string"}},"PatientId":{"name":"patientId","in":"path","required":true,"description":"UUID of the patient record","schema":{"type":"string","format":"uuid"}},"CdtName":{"name":"cdtName","in":"path","required":true,"description":"Machine-readable CDT name defined in Designer (e.g. `my_custom_type`)","schema":{"type":"string"}},"CdtId":{"name":"cdtId","in":"path","required":true,"description":"UUID of the CDT record","schema":{"type":"string","format":"uuid"}}},"schemas":{"CdtRecord":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"patientId":{"type":"string","format":"uuid"},"cdtId":{"type":"string","format":"uuid"},"version":{"type":"integer"},"cdtName":{"type":"string"},"jsonBody":{"type":"object","additionalProperties":true,"description":"Fields defined by the CDT schema, plus system fields (id, created_at, created_by, etc)."}}}},"responses":{"BadRequest":{"description":"Bad request — the request could not be understood or was missing required parameters."},"Unauthorized":{"description":"Unauthorized — the Bearer token is missing, expired, or invalid."},"Forbidden":{"description":"Forbidden — the API client role does not have permission for this resource. Check the role and security policy in Admin."},"NotFound":{"description":"Not found — the requested resource does not exist."},"TooManyRequests":{"description":"Too many requests — rate limit exceeded. Implement exponential backoff."},"InternalError":{"description":"Internal server error."}}},"paths":{"/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}/{cdtId}":{"get":{"summary":"Get CDT Record By ID","tags":["CDT Record"],"operationId":"Get_CDT_Record_By_ID","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/CdtName"},{"$ref":"#/components/parameters/CdtId"},{"name":"fields","in":"query","required":false,"schema":{"type":"string"}},{"name":"type","in":"query","required":false,"schema":{"type":"string"},"description":"Identificator type (ID, EID, EGUID), default ID"}],"responses":{"200":{"description":"CDT record","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdtRecord"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalError"}},"description":"Get cdt record by identifier (id, external_id, external_guid)\n\n1.  HTTP Request\n    \n\n***GET*** `/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}/{cdtRecordId}`\n\n2\\. In our example it would be:\n\n***GET*** `https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512`\n\n**Responses**\n\n| Code | Description |\n| --- | --- |\n| 200 | OK |\n| 401 | Unauthorized |\n| 403 | Forbidden |\n| 404 | Not Found |\n\n**Examples**\n\n1.  [https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512](https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512)\n2.  [https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/4a245aac-217e-45f4-8727-5587220dd512?type=EGUID](https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/4a245aac-217e-45f4-8727-5587220dd512?type=EGUID)\n3.  [https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/externalId?type=EID](https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/externalId?type=EID)"}}}}
````

## Delete CDT Record by ID

> Delete cdt record by id\
> \
> 1\.  HTTP Request\
> &#x20;   \
> \
> \*\*\*DELETE\*\*\* \`/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}/{cdtRecordId}\`\
> \
> 2\\. In our example it would be:\
> \
> \*\*\*DELETE\*\*\* \`<https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512\\`\\>
> \
> \*\*Responses\*\*\
> \
> \| Code | Description |\
> \| --- | --- |\
> \| 200 | OK |\
> \| 401 | Unauthorized |\
> \| 403 | Forbidden |\
> \| 404 | Not Found |

````json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"CDT Record","description":"CDT records in Welkin are associated with a Patient. In REST terms, they are a sub-resource to the patient object\n\nEach CDT record has a set of system fields associated with it and a set of custom fields that you will create in the designer.\n\n## Formula field type\n\nType *formula* is intended for calculating values at the time of receipt of the cdt record. The *formula* looks like a mathematical expression. See **Example 1**.\n\n> Example 1 of a simple formula\n\n```\n{\n  \"formula\": \"(2 + 2) * 2\"\n}\n\n```\n\n***Variables***\n\nThe formula supports the mechanism of variables. This allows you to reference fields in CDT and substitute values into the formula at runtime. To refer to a field, you should specify the field name and enclose it in double curly brackets. An example of a field reference is *{{some-cdt-field}}*. See **Example 2**.\n\n**Example**\n\nSome *cdt* contains two *integer* fields named *field-a* and *field-b*. The formula for calculating the sum of these fields values is as follows.\n\n> Example 2 of a sum of fields values\n\n```\n{\n  \"formula\": \"{{field-a}} + {{field-b}}\"\n}\n\n```\n\n***Functions***\n\nThe formula supports the mechanism of functions. Functions allow you to perform more complex calculations. to specify a function, you should specify **#** and then the **name** of the function and parentheses **()** to list the passed parameters. An example of a function is *#functionName(2, {{variable}})*\n\n**Example**\n\nYou want to know how many days have passed since the onset of the illness. A cdt contains a *date* field named *onset-disease*. See **Example 3**."}],"servers":[{"url":"https://api.live.welkincloud.io","description":"Welkin Health production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Bearer token obtained from `POST /{tenantName}/admin/api_clients/{clientName}`. Valid for 60 minutes."}},"parameters":{"TenantName":{"name":"tenantName","in":"path","required":true,"description":"Your organization (tenant) name, e.g. `acme-health`","schema":{"type":"string"}},"InstanceName":{"name":"instanceName","in":"path","required":true,"description":"Your environment name: `live`, `sandbox`, or a custom name","schema":{"type":"string"}},"PatientId":{"name":"patientId","in":"path","required":true,"description":"UUID of the patient record","schema":{"type":"string","format":"uuid"}},"CdtName":{"name":"cdtName","in":"path","required":true,"description":"Machine-readable CDT name defined in Designer (e.g. `my_custom_type`)","schema":{"type":"string"}},"CdtId":{"name":"cdtId","in":"path","required":true,"description":"UUID of the CDT record","schema":{"type":"string","format":"uuid"}}},"responses":{"BadRequest":{"description":"Bad request — the request could not be understood or was missing required parameters."},"Unauthorized":{"description":"Unauthorized — the Bearer token is missing, expired, or invalid."},"Forbidden":{"description":"Forbidden — the API client role does not have permission for this resource. Check the role and security policy in Admin."},"NotFound":{"description":"Not found — the requested resource does not exist."},"TooManyRequests":{"description":"Too many requests — rate limit exceeded. Implement exponential backoff."},"InternalError":{"description":"Internal server error."}}},"paths":{"/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}/{cdtId}":{"delete":{"summary":"Delete CDT Record by ID","tags":["CDT Record"],"operationId":"Delete_CDT_Record_by_ID","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/CdtName"},{"$ref":"#/components/parameters/CdtId"}],"responses":{"200":{"description":"CDT record deleted"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalError"}},"description":"Delete cdt record by id\n\n1.  HTTP Request\n    \n\n***DELETE*** `/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}/{cdtRecordId}`\n\n2\\. In our example it would be:\n\n***DELETE*** `https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512`\n\n**Responses**\n\n| Code | Description |\n| --- | --- |\n| 200 | OK |\n| 401 | Unauthorized |\n| 403 | Forbidden |\n| 404 | Not Found |"}}}}
````

## Update CDT Record by ID

> Update cdt record by id\
> \
> 1\.  HTTP Request\
> &#x20;   \
> \
> \*\*\*PATCH\*\*\* \`/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}/{cdtRecordId}\`\
> \
> 2\\. In our example it would be:\
> \
> \*\*\*PATCH\*\*\* \`<https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512\\`\\>
> \
> \*\*Responses\*\*\
> \
> \| Code | Description |\
> \| --- | --- |\
> \| 200 | OK |\
> \| 401 | Unauthorized |\
> \| 403 | Forbidden |\
> \| 404 | Not Found |

````json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"CDT Record","description":"CDT records in Welkin are associated with a Patient. In REST terms, they are a sub-resource to the patient object\n\nEach CDT record has a set of system fields associated with it and a set of custom fields that you will create in the designer.\n\n## Formula field type\n\nType *formula* is intended for calculating values at the time of receipt of the cdt record. The *formula* looks like a mathematical expression. See **Example 1**.\n\n> Example 1 of a simple formula\n\n```\n{\n  \"formula\": \"(2 + 2) * 2\"\n}\n\n```\n\n***Variables***\n\nThe formula supports the mechanism of variables. This allows you to reference fields in CDT and substitute values into the formula at runtime. To refer to a field, you should specify the field name and enclose it in double curly brackets. An example of a field reference is *{{some-cdt-field}}*. See **Example 2**.\n\n**Example**\n\nSome *cdt* contains two *integer* fields named *field-a* and *field-b*. The formula for calculating the sum of these fields values is as follows.\n\n> Example 2 of a sum of fields values\n\n```\n{\n  \"formula\": \"{{field-a}} + {{field-b}}\"\n}\n\n```\n\n***Functions***\n\nThe formula supports the mechanism of functions. Functions allow you to perform more complex calculations. to specify a function, you should specify **#** and then the **name** of the function and parentheses **()** to list the passed parameters. An example of a function is *#functionName(2, {{variable}})*\n\n**Example**\n\nYou want to know how many days have passed since the onset of the illness. A cdt contains a *date* field named *onset-disease*. See **Example 3**."}],"servers":[{"url":"https://api.live.welkincloud.io","description":"Welkin Health production API"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Bearer token obtained from `POST /{tenantName}/admin/api_clients/{clientName}`. Valid for 60 minutes."}},"parameters":{"TenantName":{"name":"tenantName","in":"path","required":true,"description":"Your organization (tenant) name, e.g. `acme-health`","schema":{"type":"string"}},"InstanceName":{"name":"instanceName","in":"path","required":true,"description":"Your environment name: `live`, `sandbox`, or a custom name","schema":{"type":"string"}},"PatientId":{"name":"patientId","in":"path","required":true,"description":"UUID of the patient record","schema":{"type":"string","format":"uuid"}},"CdtName":{"name":"cdtName","in":"path","required":true,"description":"Machine-readable CDT name defined in Designer (e.g. `my_custom_type`)","schema":{"type":"string"}},"CdtId":{"name":"cdtId","in":"path","required":true,"description":"UUID of the CDT record","schema":{"type":"string","format":"uuid"}}},"schemas":{"CdtRecord":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"patientId":{"type":"string","format":"uuid"},"cdtId":{"type":"string","format":"uuid"},"version":{"type":"integer"},"cdtName":{"type":"string"},"jsonBody":{"type":"object","additionalProperties":true,"description":"Fields defined by the CDT schema, plus system fields (id, created_at, created_by, etc)."}}}},"responses":{"BadRequest":{"description":"Bad request — the request could not be understood or was missing required parameters."},"Unauthorized":{"description":"Unauthorized — the Bearer token is missing, expired, or invalid."},"Forbidden":{"description":"Forbidden — the API client role does not have permission for this resource. Check the role and security policy in Admin."},"NotFound":{"description":"Not found — the requested resource does not exist."},"TooManyRequests":{"description":"Too many requests — rate limit exceeded. Implement exponential backoff."},"InternalError":{"description":"Internal server error."}}},"paths":{"/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}/{cdtId}":{"patch":{"summary":"Update CDT Record by ID","tags":["CDT Record"],"operationId":"Update_CDT_Record_by_ID","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/CdtName"},{"$ref":"#/components/parameters/CdtId"}],"responses":{"200":{"description":"Updated CDT record","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdtRecord"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"$ref":"#/components/responses/InternalError"}},"description":"Update cdt record by id\n\n1.  HTTP Request\n    \n\n***PATCH*** `/{tenantName}/{instanceName}/patients/{patientId}/cdts/{cdtName}/{cdtRecordId}`\n\n2\\. In our example it would be:\n\n***PATCH*** `https://api.live.welkincloud.io/gh/sb-demo/patients/d6ea79ce-d3d6-4c2d-a27e-e4d1207f60f1/cdts/vitals/8c0684ac-217e-45f4-8727-5587220dd512`\n\n**Responses**\n\n| Code | Description |\n| --- | --- |\n| 200 | OK |\n| 401 | Unauthorized |\n| 403 | Forbidden |\n| 404 | Not Found |","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"description":"Partial field values to update."}}}}}}}}
````


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.welkinhealth.com/api-reference/cdt-record.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
