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

# Send Email

## Send AI-Generated Message

> Send a personalized message generated by AI using your prompt and data.\
> \
> \## SDK Examples\
> \
> \### Node.js\
> \`\`\`javascript\
> const ContactedAI = require('contacted');\
> const contacted = new ContactedAI({ apiKey: 'your-api-key' });\
> \
> const result = await contacted.send({\
> &#x20; from: '<sender@example.com>',\
> &#x20; to: '<receiver@example.com>',\
> &#x20; subject: 'Welcome to our platform!',\
> &#x20; prompt: 'Generate a welcome email for a new user',\
> &#x20; data: {\
> &#x20;   name: 'John Doe',\
> &#x20;   plan: 'premium'\
> &#x20; }\
> });\
> \`\`\`\
> \
> \### Python\
> \`\`\`python\
> from contacted import ContactedAI\
> \
> contacted = ContactedAI(api\_key='your-api-key')\
> \
> result = contacted.send(\
> &#x20;   from\_email='<sender@example.com>',\
> &#x20;   to\_email='<receiver@example.com>',\
> &#x20;   subject='Welcome to our platform!',\
> &#x20;   prompt='Generate a welcome email for a new user',\
> &#x20;   data={\
> &#x20;       'name': 'John Doe',\
> &#x20;       'plan': 'premium'\
> &#x20;   }\
> )\
> \`\`\`<br>

````json
{"openapi":"3.0.3","info":{"title":"ContactedAI API","version":"0.0.11"},"tags":[{"name":"Messages","description":"Send AI-generated messages and check their status"}],"servers":[{"url":"https://api.contacted.io","description":"Production server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"http","scheme":"bearer","bearerFormat":"API_KEY","description":"Your ContactedAI API key. Get yours at [contacted.io](https://contacted.io)\n\nUse the Authorization header with Bearer scheme:\n`Authorization: Bearer CONTACTED_API_KEY_1234567890abcdef...`\n"}},"schemas":{"SendMessageRequest":{"type":"object","required":["from","to","subject","prompt"],"properties":{"from":{"type":"string","format":"email","description":"Sender email address"},"to":{"type":"string","format":"email","description":"Recipient email address"},"subject":{"type":"string","minLength":2,"maxLength":256,"description":"Email subject line.\nMust be between 2-256 characters.\n"},"prompt":{"type":"string","minLength":10,"maxLength":2000,"description":"AI prompt describing the message to generate.\nMust be between 10-2000 characters.\n"},"data":{"type":"object","description":"Additional data to personalize the message.\nKeys must be strings without spaces.\n","additionalProperties":true}}},"SendMessageResponse":{"type":"object","properties":{"id":{"type":"string","description":"Unique message identifier"},"status":{"type":"string","enum":["queued","processing","sent","failed"],"description":"Current message status"},"message":{"type":"string","description":"Human-readable status message"},"created_at":{"type":"string","format":"date-time","description":"Message creation timestamp"}}},"ErrorResponse":{"type":"object","properties":{"error":{"type":"string","description":"Error type identifier"},"message":{"type":"string","description":"Human-readable error message"},"code":{"type":"integer","description":"HTTP status code"},"retry_after":{"type":"integer","description":"Seconds to wait before retrying (for rate limits)"}}}}},"paths":{"/send":{"post":{"summary":"Send AI-Generated Message","description":"Send a personalized message generated by AI using your prompt and data.\n\n## SDK Examples\n\n### Node.js\n```javascript\nconst ContactedAI = require('contacted');\nconst contacted = new ContactedAI({ apiKey: 'your-api-key' });\n\nconst result = await contacted.send({\n  from: 'sender@example.com',\n  to: 'receiver@example.com',\n  subject: 'Welcome to our platform!',\n  prompt: 'Generate a welcome email for a new user',\n  data: {\n    name: 'John Doe',\n    plan: 'premium'\n  }\n});\n```\n\n### Python\n```python\nfrom contacted import ContactedAI\n\ncontacted = ContactedAI(api_key='your-api-key')\n\nresult = contacted.send(\n    from_email='sender@example.com',\n    to_email='receiver@example.com',\n    subject='Welcome to our platform!',\n    prompt='Generate a welcome email for a new user',\n    data={\n        'name': 'John Doe',\n        'plan': 'premium'\n    }\n)\n```\n","operationId":"sendMessage","tags":["Messages"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageRequest"}}}},"responses":{"200":{"description":"Message sent successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessageResponse"}}}},"400":{"description":"Bad Request - Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized - Invalid API Key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Rate Limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}}}
````
