> 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/email.md).

# Email

Collection of all emails would be located at the following URL:

`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`

In our example it would be:

`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`

## Get all email drafts

> Request to get drafts of an email for a patient. If a patient has a contact and you want to request drafts for them, you should specify the contact ID as the patient ID in the url request

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Email","description":"Collection of all emails would be located at the following URL:\n\n`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`\n\nIn our example it would be:\n\n`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`"}],"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"}}},"schemas":{"EmailDraftPage":{"allOf":[{"$ref":"#/components/schemas/PaginatedResponse"},{"type":"object","properties":{"content":{"type":"array","items":{"$ref":"#/components/schemas/EmailDraft"}}}}]},"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"}}},"EmailDraft":{"type":"object","required":["subject","body"],"properties":{"id":{"type":"string","format":"uuid","readOnly":true},"createdAt":{"type":"string","format":"date-time","readOnly":true},"date":{"type":"string","format":"date-time","nullable":true},"subject":{"type":"string"},"body":{"type":"string"},"emailEditorJson":{"type":"string","nullable":true},"scheduledAt":{"type":"string","format":"date-time","nullable":true},"sender":{"type":"string","format":"uuid","readOnly":true},"receiver":{"type":"string","format":"uuid","nullable":true},"patientEmail":{"type":"string","format":"email","nullable":true},"secure":{"type":"boolean","default":false},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"bodyAttachments":{"type":"array","items":{"$ref":"#/components/schemas/SignedFile"}},"priority":{"$ref":"#/components/schemas/DraftsPriority","default":"NO_PRIORITY"},"source":{"$ref":"#/components/schemas/EmailDraftSource","default":"USER"},"templateName":{"type":"string","nullable":true},"bodyType":{"$ref":"#/components/schemas/EmailBodyType","default":"PLAIN_TEXT"},"senderName":{"type":"string","readOnly":true},"receiverName":{"type":"string","readOnly":true},"status":{"$ref":"#/components/schemas/DraftsStatus","readOnly":true,"default":"WAITING"},"starred":{"type":"boolean"}}},"File":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"originalName":{"type":"string"},"size":{"type":"integer","description":"Bytes"},"contentType":{"type":"string"},"storageKey":{"type":"string"}}},"SignedFile":{"allOf":[{"$ref":"#/components/schemas/File"},{"type":"object","properties":{"url":{"type":"string","format":"uri"},"thumbnailUrl":{"type":"string","format":"uri","nullable":true}}}]},"DraftsPriority":{"type":"string","enum":["NO_PRIORITY","LOW","MEDIUM","HIGH"]},"EmailDraftSource":{"type":"string","enum":["USER","AUTOMATION"]},"EmailBodyType":{"type":"string","enum":["PLAIN_TEXT","HTML"]},"DraftsStatus":{"type":"string","enum":["WAITING","FAILED"]}},"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}/email-drafts":{"get":{"summary":"Get all email drafts","tags":["Email"],"operationId":"Get_all_email_drafts","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"name":"unscheduled","in":"query","required":false,"description":"","schema":{"type":"string"}},{"name":"search","in":"query","required":false,"schema":{"type":"string"}},{"name":"patient","in":"query","required":false,"schema":{"type":"string"}},{"name":"priorities","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"sort","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Paginated list of email drafts","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailDraftPage"}}}},"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":"Request to get drafts of an email for a patient. If a patient has a contact and you want to request drafts for them, you should specify the contact ID as the patient ID in the url request"}}}}
```

## Create email draft

> Request to create an email draft for a patient. If a patient has a contact added and you want to create a draft for him/her, then the contact's id should be specified in the request url as the patient's id (and the contact's data should be specified as the recipient as well).

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Email","description":"Collection of all emails would be located at the following URL:\n\n`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`\n\nIn our example it would be:\n\n`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`"}],"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"}}},"schemas":{"EmailDraft":{"type":"object","required":["subject","body"],"properties":{"id":{"type":"string","format":"uuid","readOnly":true},"createdAt":{"type":"string","format":"date-time","readOnly":true},"date":{"type":"string","format":"date-time","nullable":true},"subject":{"type":"string"},"body":{"type":"string"},"emailEditorJson":{"type":"string","nullable":true},"scheduledAt":{"type":"string","format":"date-time","nullable":true},"sender":{"type":"string","format":"uuid","readOnly":true},"receiver":{"type":"string","format":"uuid","nullable":true},"patientEmail":{"type":"string","format":"email","nullable":true},"secure":{"type":"boolean","default":false},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"bodyAttachments":{"type":"array","items":{"$ref":"#/components/schemas/SignedFile"}},"priority":{"$ref":"#/components/schemas/DraftsPriority","default":"NO_PRIORITY"},"source":{"$ref":"#/components/schemas/EmailDraftSource","default":"USER"},"templateName":{"type":"string","nullable":true},"bodyType":{"$ref":"#/components/schemas/EmailBodyType","default":"PLAIN_TEXT"},"senderName":{"type":"string","readOnly":true},"receiverName":{"type":"string","readOnly":true},"status":{"$ref":"#/components/schemas/DraftsStatus","readOnly":true,"default":"WAITING"},"starred":{"type":"boolean"}}},"File":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"originalName":{"type":"string"},"size":{"type":"integer","description":"Bytes"},"contentType":{"type":"string"},"storageKey":{"type":"string"}}},"SignedFile":{"allOf":[{"$ref":"#/components/schemas/File"},{"type":"object","properties":{"url":{"type":"string","format":"uri"},"thumbnailUrl":{"type":"string","format":"uri","nullable":true}}}]},"DraftsPriority":{"type":"string","enum":["NO_PRIORITY","LOW","MEDIUM","HIGH"]},"EmailDraftSource":{"type":"string","enum":["USER","AUTOMATION"]},"EmailBodyType":{"type":"string","enum":["PLAIN_TEXT","HTML"]},"DraftsStatus":{"type":"string","enum":["WAITING","FAILED"]}},"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}/email-drafts":{"post":{"summary":"Create email draft","tags":["Email"],"operationId":"Create_email_draft","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"}],"responses":{"201":{"description":"Email draft created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailDraft"}}}},"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":"Request to create an email draft for a patient. If a patient has a contact added and you want to create a draft for him/her, then the contact's id should be specified in the request url as the patient's id (and the contact's data should be specified as the recipient as well).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailDraft"}}}}}}}}
```

## Get email draft by id

> Request to get one draft of an email for a patient. If a patient has a contact and you want to request draft for them, you should specify the contact ID as the patient ID in the url request

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Email","description":"Collection of all emails would be located at the following URL:\n\n`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`\n\nIn our example it would be:\n\n`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`"}],"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"}},"Uuid":{"name":"uuid","in":"path","required":true,"description":"UUID of the resource","schema":{"type":"string","format":"uuid"}}},"schemas":{"EmailDraft":{"type":"object","required":["subject","body"],"properties":{"id":{"type":"string","format":"uuid","readOnly":true},"createdAt":{"type":"string","format":"date-time","readOnly":true},"date":{"type":"string","format":"date-time","nullable":true},"subject":{"type":"string"},"body":{"type":"string"},"emailEditorJson":{"type":"string","nullable":true},"scheduledAt":{"type":"string","format":"date-time","nullable":true},"sender":{"type":"string","format":"uuid","readOnly":true},"receiver":{"type":"string","format":"uuid","nullable":true},"patientEmail":{"type":"string","format":"email","nullable":true},"secure":{"type":"boolean","default":false},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"bodyAttachments":{"type":"array","items":{"$ref":"#/components/schemas/SignedFile"}},"priority":{"$ref":"#/components/schemas/DraftsPriority","default":"NO_PRIORITY"},"source":{"$ref":"#/components/schemas/EmailDraftSource","default":"USER"},"templateName":{"type":"string","nullable":true},"bodyType":{"$ref":"#/components/schemas/EmailBodyType","default":"PLAIN_TEXT"},"senderName":{"type":"string","readOnly":true},"receiverName":{"type":"string","readOnly":true},"status":{"$ref":"#/components/schemas/DraftsStatus","readOnly":true,"default":"WAITING"},"starred":{"type":"boolean"}}},"File":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"originalName":{"type":"string"},"size":{"type":"integer","description":"Bytes"},"contentType":{"type":"string"},"storageKey":{"type":"string"}}},"SignedFile":{"allOf":[{"$ref":"#/components/schemas/File"},{"type":"object","properties":{"url":{"type":"string","format":"uri"},"thumbnailUrl":{"type":"string","format":"uri","nullable":true}}}]},"DraftsPriority":{"type":"string","enum":["NO_PRIORITY","LOW","MEDIUM","HIGH"]},"EmailDraftSource":{"type":"string","enum":["USER","AUTOMATION"]},"EmailBodyType":{"type":"string","enum":["PLAIN_TEXT","HTML"]},"DraftsStatus":{"type":"string","enum":["WAITING","FAILED"]}},"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}/email-drafts/{uuid}":{"get":{"summary":"Get email draft by id","tags":["Email"],"operationId":"Get_email_draft_by_id","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/Uuid"}],"responses":{"200":{"description":"Email draft","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailDraft"}}}},"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":"Request to get one draft of an email for a patient. If a patient has a contact and you want to request draft for them, you should specify the contact ID as the patient ID in the url request"}}}}
```

## POST /{tenantName}/{instanceName}/patients/{patientId}/email-drafts/{uuid}

> Update attachments

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Email","description":"Collection of all emails would be located at the following URL:\n\n`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`\n\nIn our example it would be:\n\n`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`"}],"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"}},"Uuid":{"name":"uuid","in":"path","required":true,"description":"UUID of the resource","schema":{"type":"string","format":"uuid"}}},"schemas":{"EmailDraft":{"type":"object","required":["subject","body"],"properties":{"id":{"type":"string","format":"uuid","readOnly":true},"createdAt":{"type":"string","format":"date-time","readOnly":true},"date":{"type":"string","format":"date-time","nullable":true},"subject":{"type":"string"},"body":{"type":"string"},"emailEditorJson":{"type":"string","nullable":true},"scheduledAt":{"type":"string","format":"date-time","nullable":true},"sender":{"type":"string","format":"uuid","readOnly":true},"receiver":{"type":"string","format":"uuid","nullable":true},"patientEmail":{"type":"string","format":"email","nullable":true},"secure":{"type":"boolean","default":false},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"bodyAttachments":{"type":"array","items":{"$ref":"#/components/schemas/SignedFile"}},"priority":{"$ref":"#/components/schemas/DraftsPriority","default":"NO_PRIORITY"},"source":{"$ref":"#/components/schemas/EmailDraftSource","default":"USER"},"templateName":{"type":"string","nullable":true},"bodyType":{"$ref":"#/components/schemas/EmailBodyType","default":"PLAIN_TEXT"},"senderName":{"type":"string","readOnly":true},"receiverName":{"type":"string","readOnly":true},"status":{"$ref":"#/components/schemas/DraftsStatus","readOnly":true,"default":"WAITING"},"starred":{"type":"boolean"}}},"File":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"originalName":{"type":"string"},"size":{"type":"integer","description":"Bytes"},"contentType":{"type":"string"},"storageKey":{"type":"string"}}},"SignedFile":{"allOf":[{"$ref":"#/components/schemas/File"},{"type":"object","properties":{"url":{"type":"string","format":"uri"},"thumbnailUrl":{"type":"string","format":"uri","nullable":true}}}]},"DraftsPriority":{"type":"string","enum":["NO_PRIORITY","LOW","MEDIUM","HIGH"]},"EmailDraftSource":{"type":"string","enum":["USER","AUTOMATION"]},"EmailBodyType":{"type":"string","enum":["PLAIN_TEXT","HTML"]},"DraftsStatus":{"type":"string","enum":["WAITING","FAILED"]}},"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}/email-drafts/{uuid}":{"post":{"summary":"Update attachments","tags":["Email"],"operationId":"Update_attachments","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/Uuid"}],"responses":{"200":{"description":"Email draft with attachments added","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailDraft"}}}},"201":{"description":"Success"},"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"}},"requestBody":{"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"attachmentsAsFiles":{"type":"array","items":{"type":"string","format":"binary"}}}}}}}}}}}
```

## DELETE /{tenantName}/{instanceName}/patients/{patientId}/email-drafts/{uuid}

> Delete email draft

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Email","description":"Collection of all emails would be located at the following URL:\n\n`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`\n\nIn our example it would be:\n\n`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`"}],"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"}},"Uuid":{"name":"uuid","in":"path","required":true,"description":"UUID of the resource","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}/email-drafts/{uuid}":{"delete":{"summary":"Delete email draft","tags":["Email"],"operationId":"Delete_email_draft","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/Uuid"}],"responses":{"200":{"description":"Email draft 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"}}}}}}
```

## PATCH /{tenantName}/{instanceName}/patients/{patientId}/email-drafts/{uuid}

> Update email draft

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Email","description":"Collection of all emails would be located at the following URL:\n\n`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`\n\nIn our example it would be:\n\n`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`"}],"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"}},"Uuid":{"name":"uuid","in":"path","required":true,"description":"UUID of the resource","schema":{"type":"string","format":"uuid"}}},"schemas":{"EmailDraft":{"type":"object","required":["subject","body"],"properties":{"id":{"type":"string","format":"uuid","readOnly":true},"createdAt":{"type":"string","format":"date-time","readOnly":true},"date":{"type":"string","format":"date-time","nullable":true},"subject":{"type":"string"},"body":{"type":"string"},"emailEditorJson":{"type":"string","nullable":true},"scheduledAt":{"type":"string","format":"date-time","nullable":true},"sender":{"type":"string","format":"uuid","readOnly":true},"receiver":{"type":"string","format":"uuid","nullable":true},"patientEmail":{"type":"string","format":"email","nullable":true},"secure":{"type":"boolean","default":false},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"bodyAttachments":{"type":"array","items":{"$ref":"#/components/schemas/SignedFile"}},"priority":{"$ref":"#/components/schemas/DraftsPriority","default":"NO_PRIORITY"},"source":{"$ref":"#/components/schemas/EmailDraftSource","default":"USER"},"templateName":{"type":"string","nullable":true},"bodyType":{"$ref":"#/components/schemas/EmailBodyType","default":"PLAIN_TEXT"},"senderName":{"type":"string","readOnly":true},"receiverName":{"type":"string","readOnly":true},"status":{"$ref":"#/components/schemas/DraftsStatus","readOnly":true,"default":"WAITING"},"starred":{"type":"boolean"}}},"File":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"originalName":{"type":"string"},"size":{"type":"integer","description":"Bytes"},"contentType":{"type":"string"},"storageKey":{"type":"string"}}},"SignedFile":{"allOf":[{"$ref":"#/components/schemas/File"},{"type":"object","properties":{"url":{"type":"string","format":"uri"},"thumbnailUrl":{"type":"string","format":"uri","nullable":true}}}]},"DraftsPriority":{"type":"string","enum":["NO_PRIORITY","LOW","MEDIUM","HIGH"]},"EmailDraftSource":{"type":"string","enum":["USER","AUTOMATION"]},"EmailBodyType":{"type":"string","enum":["PLAIN_TEXT","HTML"]},"DraftsStatus":{"type":"string","enum":["WAITING","FAILED"]}},"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}/email-drafts/{uuid}":{"patch":{"summary":"Update email draft","tags":["Email"],"operationId":"Update_email_draft","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/Uuid"}],"responses":{"200":{"description":"Updated email draft","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailDraft"}}}},"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"}},"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailDraft"}}}}}}}}
```

## Get all Emails

> Following Query Parameters can be used to sort or find approporiately\
> \
> We can use any combination of this parameters in single request: Example: \`{{url}}/{{tenantName}}/{{instanceName}}/patients/{{patientId}}/emails?status=DELIVERED,FAILED\&email=<some-email@email.com>\&starred=true\`

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Email","description":"Collection of all emails would be located at the following URL:\n\n`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`\n\nIn our example it would be:\n\n`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`"}],"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"}},"Sort":{"name":"sort","in":"query","required":false,"description":"Sort field and direction, e.g. `lastName,asc` or `createdAt,desc`","schema":{"type":"string"}}},"schemas":{"EmailPage":{"allOf":[{"$ref":"#/components/schemas/PaginatedResponse"},{"type":"object","properties":{"content":{"type":"array","items":{"$ref":"#/components/schemas/Email"}}}}]},"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"}}},"Email":{"type":"object","required":["sender","body"],"properties":{"id":{"type":"string","format":"uuid","readOnly":true},"createdAt":{"type":"string","format":"date-time","readOnly":true},"updatedAt":{"type":"string","format":"date-time","readOnly":true},"createdBy":{"type":"string","format":"uuid","readOnly":true},"updatedBy":{"type":"string","format":"uuid","readOnly":true},"createdByName":{"type":"string","readOnly":true},"updatedByName":{"type":"string","readOnly":true},"sendNow":{"type":"boolean"},"sentAt":{"type":"string","format":"date-time","nullable":true},"receivedAt":{"type":"string","format":"date-time","nullable":true},"deletedAt":{"type":"string","format":"date-time","nullable":true},"date":{"type":"string","format":"date-time","nullable":true},"careTeam":{"type":"string","nullable":true},"patientInfo":{"type":"string","nullable":true},"sender":{"type":"string","format":"uuid"},"senderType":{"$ref":"#/components/schemas/ActorType"},"senderName":{"type":"string","nullable":true},"from":{"type":"string","nullable":true},"receiver":{"type":"string","format":"uuid","nullable":true},"receiverType":{"$ref":"#/components/schemas/ActorType"},"receiverName":{"type":"string","nullable":true},"to":{"type":"string","nullable":true},"direction":{"$ref":"#/components/schemas/Direction"},"externalId":{"type":"string","nullable":true},"starred":{"type":"boolean"},"errorMessage":{"type":"string","nullable":true},"assignedBy":{"type":"string","format":"uuid","readOnly":true,"nullable":true},"assignedByName":{"type":"string","readOnly":true,"nullable":true},"hasHistory":{"type":"boolean","readOnly":true},"unrecognized":{"type":"boolean","readOnly":true},"subject":{"type":"string","nullable":true},"body":{"type":"string"},"emailEditorJson":{"type":"string","nullable":true},"status":{"$ref":"#/components/schemas/EmailStatus"},"secure":{"type":"boolean","default":false},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/File"},"readOnly":true},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"bodyAttachments":{"type":"array","items":{"$ref":"#/components/schemas/SignedFile"}},"messageType":{"$ref":"#/components/schemas/MessageType","default":"CARE_TEAM"},"bodyType":{"$ref":"#/components/schemas/EmailBodyType","default":"PLAIN_TEXT"},"inReplyTo":{"type":"string","nullable":true},"messageId":{"type":"string","nullable":true},"skipEvent":{"type":"boolean"}}},"ActorType":{"type":"string","enum":["CS_TOOL_CLIENT","USER","API_CLIENT","PATIENT","CONTACT","SYSTEM","WEBHOOK","INTERNAL_SERVICE","ANONYMOUS","UNRECOGNISED"]},"Direction":{"type":"string","enum":["OUT","IN"]},"EmailStatus":{"type":"string","enum":["SCHEDULED","ACCEPTED","SENT","DELIVERED","REJECTED","FAILED","UNRECOGNISED","DELETED","CLICKED","OPENED"]},"File":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"originalName":{"type":"string"},"size":{"type":"integer","description":"Bytes"},"contentType":{"type":"string"},"storageKey":{"type":"string"}}},"SignedFile":{"allOf":[{"$ref":"#/components/schemas/File"},{"type":"object","properties":{"url":{"type":"string","format":"uri"},"thumbnailUrl":{"type":"string","format":"uri","nullable":true}}}]},"MessageType":{"type":"string","enum":["CARE_TEAM","SYSTEM_TO_USER","SYSTEM_TO_PATIENT"]},"EmailBodyType":{"type":"string","enum":["PLAIN_TEXT","HTML"]}},"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}/emails":{"get":{"summary":"Get all Emails","tags":["Email"],"operationId":"Get_all_Emails","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/Sort"},{"name":"receiver","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, search by receiver id"},{"name":"direction","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, search by direction (IN or OUT)"},{"name":"page","in":"query","required":false,"schema":{"type":"integer","default":0,"minimum":0},"description":"When specified, page number"},{"name":"size","in":"query","required":false,"schema":{"type":"integer","default":20},"description":"When specified, size per page"},{"name":"starred","in":"query","required":false,"schema":{"type":"boolean"},"description":"When specified, search by starred (boolean value) field (as an important email)"},{"name":"externalId","in":"query","required":false,"schema":{"type":"string"}},{"name":"email","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, search by 'to' or 'from' email"},{"name":"fromDate","in":"query","required":false,"schema":{"type":"string","format":"date-time"}},{"name":"toDate","in":"query","required":false,"schema":{"type":"string","format":"date-time"}},{"name":"search","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, will execute a search based on subject and body fields"},{"name":"sender","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, search by sender id"},{"name":"from","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, search by 'from' email"},{"name":"to","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, search by 'to' email"},{"name":"senderName","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, search by sender name"},{"name":"receiverName","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, search by receiver name"},{"name":"status","in":"query","required":false,"schema":{"type":"string"},"description":"When specified, search by status [SCHEDULED, ACCEPTED, DELIVERED, REJECTED, FAILED, UNRECOGNISED]"}],"responses":{"200":{"description":"Paginated list of emails","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailPage"}}}},"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":"Following Query Parameters can be used to sort or find approporiately\n\nWe can use any combination of this parameters in single request: Example: `{{url}}/{{tenantName}}/{{instanceName}}/patients/{{patientId}}/emails?status=DELIVERED,FAILED&email=some-email@email.com&starred=true`"}}}}
```

## Get Email by ID

> Getting an email by ID

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Email","description":"Collection of all emails would be located at the following URL:\n\n`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`\n\nIn our example it would be:\n\n`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`"}],"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"}},"Uuid":{"name":"uuid","in":"path","required":true,"description":"UUID of the resource","schema":{"type":"string","format":"uuid"}}},"schemas":{"Email":{"type":"object","required":["sender","body"],"properties":{"id":{"type":"string","format":"uuid","readOnly":true},"createdAt":{"type":"string","format":"date-time","readOnly":true},"updatedAt":{"type":"string","format":"date-time","readOnly":true},"createdBy":{"type":"string","format":"uuid","readOnly":true},"updatedBy":{"type":"string","format":"uuid","readOnly":true},"createdByName":{"type":"string","readOnly":true},"updatedByName":{"type":"string","readOnly":true},"sendNow":{"type":"boolean"},"sentAt":{"type":"string","format":"date-time","nullable":true},"receivedAt":{"type":"string","format":"date-time","nullable":true},"deletedAt":{"type":"string","format":"date-time","nullable":true},"date":{"type":"string","format":"date-time","nullable":true},"careTeam":{"type":"string","nullable":true},"patientInfo":{"type":"string","nullable":true},"sender":{"type":"string","format":"uuid"},"senderType":{"$ref":"#/components/schemas/ActorType"},"senderName":{"type":"string","nullable":true},"from":{"type":"string","nullable":true},"receiver":{"type":"string","format":"uuid","nullable":true},"receiverType":{"$ref":"#/components/schemas/ActorType"},"receiverName":{"type":"string","nullable":true},"to":{"type":"string","nullable":true},"direction":{"$ref":"#/components/schemas/Direction"},"externalId":{"type":"string","nullable":true},"starred":{"type":"boolean"},"errorMessage":{"type":"string","nullable":true},"assignedBy":{"type":"string","format":"uuid","readOnly":true,"nullable":true},"assignedByName":{"type":"string","readOnly":true,"nullable":true},"hasHistory":{"type":"boolean","readOnly":true},"unrecognized":{"type":"boolean","readOnly":true},"subject":{"type":"string","nullable":true},"body":{"type":"string"},"emailEditorJson":{"type":"string","nullable":true},"status":{"$ref":"#/components/schemas/EmailStatus"},"secure":{"type":"boolean","default":false},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/File"},"readOnly":true},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"bodyAttachments":{"type":"array","items":{"$ref":"#/components/schemas/SignedFile"}},"messageType":{"$ref":"#/components/schemas/MessageType","default":"CARE_TEAM"},"bodyType":{"$ref":"#/components/schemas/EmailBodyType","default":"PLAIN_TEXT"},"inReplyTo":{"type":"string","nullable":true},"messageId":{"type":"string","nullable":true},"skipEvent":{"type":"boolean"}}},"ActorType":{"type":"string","enum":["CS_TOOL_CLIENT","USER","API_CLIENT","PATIENT","CONTACT","SYSTEM","WEBHOOK","INTERNAL_SERVICE","ANONYMOUS","UNRECOGNISED"]},"Direction":{"type":"string","enum":["OUT","IN"]},"EmailStatus":{"type":"string","enum":["SCHEDULED","ACCEPTED","SENT","DELIVERED","REJECTED","FAILED","UNRECOGNISED","DELETED","CLICKED","OPENED"]},"File":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"originalName":{"type":"string"},"size":{"type":"integer","description":"Bytes"},"contentType":{"type":"string"},"storageKey":{"type":"string"}}},"SignedFile":{"allOf":[{"$ref":"#/components/schemas/File"},{"type":"object","properties":{"url":{"type":"string","format":"uri"},"thumbnailUrl":{"type":"string","format":"uri","nullable":true}}}]},"MessageType":{"type":"string","enum":["CARE_TEAM","SYSTEM_TO_USER","SYSTEM_TO_PATIENT"]},"EmailBodyType":{"type":"string","enum":["PLAIN_TEXT","HTML"]}},"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}/emails/{uuid}":{"get":{"summary":"Get Email by ID","tags":["Email"],"operationId":"Get_Email_by_ID","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"$ref":"#/components/parameters/Uuid"}],"responses":{"200":{"description":"Email record","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Email"}}}},"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":"Getting an email by ID"}}}}
```

## Download email attachment

> Request to receive email attachment.\
> \
> emailId - email ID\
> \
> fileId - file id to be taken from the attachments block

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Email","description":"Collection of all emails would be located at the following URL:\n\n`{{url}} / {{tenantName}} / {{instanceName}} / patients / {{patientId}} / emails`\n\nIn our example it would be:\n\n`https://api.live.welkincloud.io/gh/sb-demo/patients/5da47c49-0c2b-4239-b438-7a826d407739/emails`"}],"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"}},"FileId":{"name":"fileId","in":"path","required":true,"description":"UUID of the uploaded file","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}/emails/{emailId}/attachments/{fileId}":{"get":{"summary":"Download email attachment","tags":["Email"],"operationId":"Download_email_attachment","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"$ref":"#/components/parameters/PatientId"},{"name":"emailId","in":"path","required":true,"description":"`emailId` path parameter","schema":{"type":"string","format":"uuid"}},{"$ref":"#/components/parameters/FileId"}],"responses":{"200":{"description":"Binary attachment file."},"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":"Request to receive email attachment.\n\nemailId - email ID\n\nfileId - file id to be taken from the attachments block"}}}}
```


---

# 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/email.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.
