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

# Communication API

## Create communication id SMS

> Step 1 of sending a message: generates a \`communicationId\` for the given channel and patient contact. No message is sent and no resource is created by this call alone — pass the returned \`communicationId\` to \`POST /{communicationId}/messages\` to actually send it. Confirmed against \`welikan-communication-proxy-service\` (\`CommunicationController.createCommunicationId\`).

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Communication API","description":""}],"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"}}},"schemas":{"CreateCommunicationIdResponse":{"type":"object","properties":{"communicationId":{"type":"string","description":"Opaque token to pass to the send-message endpoint. Not a persisted resource — it is a Base64 encoding of the request above, decoded server-side on the next call."}}},"CreateCommunicationIdRequest":{"type":"object","required":["channel","patientContactId"],"properties":{"channel":{"$ref":"#/components/schemas/Channel"},"patientContactId":{"type":"string","format":"uuid"},"instancePhoneId":{"type":"string","format":"uuid","description":"Required for SMS/VOICE_CALL if patientContactPhoneNumber is not the default."},"patientContactPhoneNumber":{"type":"string","description":"E.164 format. If omitted for SMS/VOICE_CALL, the patient contact's default phone is used."}}},"Channel":{"type":"string","enum":["SMS","EMAIL","VOICE_CALL"]}},"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}/communications":{"post":{"summary":"Create communication id SMS","tags":["Communication API"],"operationId":"Create_communication_id_SMS","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"}],"responses":{"200":{"description":"Communication ID generated (no resource is persisted).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCommunicationIdResponse"}}}},"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":"Step 1 of sending a message: generates a `communicationId` for the given channel and patient contact. No message is sent and no resource is created by this call alone — pass the returned `communicationId` to `POST /{communicationId}/messages` to actually send it. Confirmed against `welikan-communication-proxy-service` (`CommunicationController.createCommunicationId`).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCommunicationIdRequest"}}}}}}}}
```

## Send message

> Step 2 of sending a message: sends the actual message on the channel established by the \`communicationId\`. Request shape depends on that channel: SMS needs \`message\`; Email needs \`message\` + \`subject\` (+ optional \`secure\`); Voice Call takes only \`recorded\`. For SMS/Email, use \`multipart/form-data\` instead to attach files via \`attachmentsAsFiles\`. The response is the created SMS/Email/Voice Call record from the underlying resource, matching the corresponding resource schema in the SMS/Email/Calls sections of this API. Confirmed against \`welikan-communication-proxy-service\` (\`MessageController.createAndSendMessage\`), which proxies to the corresponding \`welikan\` monolith endpoint.

```json
{"openapi":"3.0.3","info":{"title":"Welkin Health API","version":"1.0.0"},"tags":[{"name":"Communication API","description":""}],"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"}}},"schemas":{"SmsMessageRequest":{"type":"object","required":["message"],"properties":{"message":{"type":"string","maxLength":1600},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}}}},"File":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"originalName":{"type":"string"},"size":{"type":"integer","description":"Bytes"},"contentType":{"type":"string"},"storageKey":{"type":"string"}}},"EmailMessageRequest":{"type":"object","required":["message","subject"],"properties":{"message":{"type":"string"},"subject":{"type":"string"},"secure":{"type":"boolean","default":false},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}}}},"VoiceCallMessageRequest":{"type":"object","properties":{"recorded":{"type":"boolean","default":false}}},"SmsMessageMultipartRequest":{"type":"object","required":["message"],"properties":{"message":{"type":"string"},"attachmentsAsFiles":{"type":"array","items":{"type":"string","format":"binary"}}}},"EmailMessageMultipartRequest":{"type":"object","required":["message","subject"],"properties":{"message":{"type":"string"},"subject":{"type":"string"},"secure":{"type":"boolean","default":false},"attachmentsAsFiles":{"type":"array","items":{"type":"string","format":"binary"}}}},"Sms":{"type":"object","required":["sender","message"],"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},"message":{"type":"string","maxLength":1600},"parts":{"type":"integer","readOnly":true},"status":{"$ref":"#/components/schemas/SmsStatus"},"messageType":{"$ref":"#/components/schemas/MessageType","default":"CARE_TEAM"},"phoneId":{"type":"string","format":"uuid"},"attachments":{"type":"array","items":{"$ref":"#/components/schemas/File"},"readOnly":true},"attachmentsFromTemplate":{"type":"array","items":{"$ref":"#/components/schemas/File"}},"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"]},"SmsStatus":{"type":"string","enum":["SCHEDULED","ACCEPTED","SENT","RECEIVED","DELIVERED","UNDELIVERED","FAILED","UNRECOGNISED","DELETED"]},"MessageType":{"type":"string","enum":["CARE_TEAM","SYSTEM_TO_USER","SYSTEM_TO_PATIENT"]},"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"}}},"EmailStatus":{"type":"string","enum":["SCHEDULED","ACCEPTED","SENT","DELIVERED","REJECTED","FAILED","UNRECOGNISED","DELETED","CLICKED","OPENED"]},"SignedFile":{"allOf":[{"$ref":"#/components/schemas/File"},{"type":"object","properties":{"url":{"type":"string","format":"uri"},"thumbnailUrl":{"type":"string","format":"uri","nullable":true}}}]},"EmailBodyType":{"type":"string","enum":["PLAIN_TEXT","HTML"]},"VoiceCall":{"type":"object","required":["sender"],"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},"childCallSid":{"type":"string","nullable":true},"parentCallStatus":{"$ref":"#/components/schemas/VoiceCallStatus"},"childCallStatus":{"$ref":"#/components/schemas/VoiceCallStatus"},"userPhone":{"type":"string","nullable":true},"parentCallDuration":{"type":"integer","nullable":true},"childCallDuration":{"type":"integer","nullable":true},"recorded":{"type":"boolean"},"recordingDuration":{"type":"integer","nullable":true},"recordingSid":{"type":"string","nullable":true},"recordingUrl":{"type":"string","nullable":true},"recordingFile":{"$ref":"#/components/schemas/File","nullable":true},"phoneId":{"type":"string","format":"uuid","nullable":true}}},"VoiceCallStatus":{"type":"string","enum":["QUEUED","INITIATED","RINGING","IN_PROGRESS","COMPLETED","BUSY","NO_ANSWER","CANCELED","FAILED"]},"CommunicationError":{"type":"object","properties":{"errorCode":{"type":"string","enum":["VALIDATION_ERROR","COMMUNICATION_ID_INVALID_ERROR","CHANNEL_TYPE_INVALID_ERROR","COMMUNICATION_ERROR","GENERIC","UNKNOWN_ERROR"]},"componentType":{"type":"string","nullable":true},"message":{"type":"string"},"details":{"$ref":"#/components/schemas/CommunicationErrorDetails"},"date":{"type":"string","format":"date-time"}}},"CommunicationErrorDetails":{"type":"object","properties":{"fieldName":{"type":"string","nullable":true},"value":{"description":"The offending value, if applicable. Type varies."}}}},"responses":{"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."}}},"paths":{"/{tenantName}/{instanceName}/{communicationId}/messages":{"post":{"summary":"Send message","tags":["Communication API"],"operationId":"Send_Message","parameters":[{"$ref":"#/components/parameters/TenantName"},{"$ref":"#/components/parameters/InstanceName"},{"name":"communicationId","in":"path","required":true,"description":"Opaque token returned by `POST /communications`.","schema":{"type":"string"}}],"description":"Step 2 of sending a message: sends the actual message on the channel established by the `communicationId`. Request shape depends on that channel: SMS needs `message`; Email needs `message` + `subject` (+ optional `secure`); Voice Call takes only `recorded`. For SMS/Email, use `multipart/form-data` instead to attach files via `attachmentsAsFiles`. The response is the created SMS/Email/Voice Call record from the underlying resource, matching the corresponding resource schema in the SMS/Email/Calls sections of this API. Confirmed against `welikan-communication-proxy-service` (`MessageController.createAndSendMessage`), which proxies to the corresponding `welikan` monolith endpoint.","requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/SmsMessageRequest"},{"$ref":"#/components/schemas/EmailMessageRequest"},{"$ref":"#/components/schemas/VoiceCallMessageRequest"}]}},"multipart/form-data":{"schema":{"oneOf":[{"$ref":"#/components/schemas/SmsMessageMultipartRequest"},{"$ref":"#/components/schemas/EmailMessageMultipartRequest"}]}}}},"responses":{"200":{"description":"Message sent — response shape matches the SMS/Email/Voice Call resource for the channel used.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Sms"},{"$ref":"#/components/schemas/Email"},{"$ref":"#/components/schemas/VoiceCall"}]}}}},"400":{"description":"Validation error, invalid communicationId, or invalid channel.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CommunicationError"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"},"500":{"description":"Downstream communication error or unexpected failure.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CommunicationError"}}}}}}}}}}
```


---

# 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/communication-api.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.
