# Mail an Bewerbende senden

`POST https://{tenant}.stamp.eu/rest/recruiting/applications/{application}/mails`

Queues a rejection or invitation and records a
`mail_sent` event; `set_stage` moves a rejection to `rejected` in the same request. Answers
202 with the event and the updated application. 409 `application_purged`, 422
`application_without_email` or field errors

## Pfadparameter

| Name | Typ | Pflicht |
| --- | --- | --- |
| `application` | string | ja |

## Request-Body

| Feld | Typ | Pflicht | Beschreibung |
| --- | --- | --- | --- |
| `template` | `rejection`, `invitation` | ja | Mail templates of the recruiting pipeline (OpenSpec add-recruiting, D11 Stufe 2, task 9.1): the rejection and the invitation, each a tenant setting with a default text per tenant language. |
| `subject` | string \| null | nein |  |
| `body` | string \| null | nein |  |
| `set_stage` | boolean | nein |  |

## Antworten

### 202: `JobApplicationMailSentResource`

| Feld | Typ | Pflicht | Beschreibung |
| --- | --- | --- | --- |
| `data` | object | ja |  |
| `data.event` | object | ja |  |
| `data.event.id` | string | ja |  |
| `data.event.type` | `stage_changed`, `note`, `mail_sent`, `converted` | ja | Entry in the history of a job application (OpenSpec add-recruiting, D3, D7, D11, D14). |
| `data.event.from_stage` | `new`, `review`, `interview`, `offer`, `hired`, `rejected` \| null | ja |  |
| `data.event.to_stage` | `new`, `review`, `interview`, `offer`, `hired`, `rejected` \| null | ja |  |
| `data.event.body` | string \| null | ja |  |
| `data.event.mail_template` | `rejection`, `invitation` \| null | ja |  |
| `data.event.mail_subject` | string \| null | ja |  |
| `data.event.user_id` | string \| null | ja |  |
| `data.event.user_name` | string \| null | ja |  |
| `data.event.created_at` | string \| null | ja |  |
| `data.application` | object | ja |  |
| `data.application.id` | string | ja |  |
| `data.application.job_posting_id` | string | ja |  |
| `data.application.posting` | object \| null | ja |  |
| `data.application.first_name` | string \| null | ja |  |
| `data.application.last_name` | string \| null | ja |  |
| `data.application.full_name` | string \| null | ja |  |
| `data.application.email` | string \| null | ja |  |
| `data.application.phone` | string \| null | ja |  |
| `data.application.profile_url` | string \| null | ja |  |
| `data.application.cover_letter` | string \| null | ja |  |
| `data.application.stage` | `new`, `review`, `interview`, `offer`, `hired`, `rejected` | ja | Fixed pipeline of a job application (OpenSpec add-recruiting, D7). Every transition is allowed, also backwards; entering `rejected` or `hired` sets the matching timestamp, leaving it clears it. |
| `data.application.source` | `career_page`, `widget`, `indeed`, `stepstone`, `linkedin`, `aggregator` | ja | Where an application came from (OpenSpec add-recruiting, D16, D17): the hosted career page, the job widget or one of the feed channels. The public job page passes the value of `?source=` to the submission; the feed channels append it to every posting URL (`tracking_source` in `recruiting.feeds.channels`). Unknown values count as career page. |
| `data.application.locale` | string | ja |  |
| `data.application.privacy_acknowledged_at` | string | ja |  |
| `data.application.privacy_notice_version` | integer | ja |  |
| `data.application.submitted_at` | string \| null | ja |  |
| `data.application.rejected_at` | string \| null | ja |  |
| `data.application.hired_at` | string \| null | ja |  |
| `data.application.employee_id` | string \| null | ja |  |
| `data.application.is_purged` | boolean | ja |  |
| `data.application.purged_at` | string \| null | ja |  |
| `data.application.possible_duplicate` | boolean | ja |  |
| `data.application.duplicate_count` | integer | ja |  |
| `data.application.duplicate_on_posting_count` | integer | ja |  |
| `data.application.retention_due_at` | string \| null | ja |  |
| `data.application.retention_hint` | boolean | ja |  |
| `data.application.mail_templates` | `rejection`, `invitation`[] | ja |  |
| `data.application.can_convert` | boolean | ja |  |
| `data.application.can_create_questionnaire` | boolean | ja |  |
| `data.application.documents` | object[] | ja |  |
| `data.application.events` | object[] | ja |  |

### 401: Unauthenticated

| Feld | Typ | Pflicht | Beschreibung |
| --- | --- | --- | --- |
| `message` | string | ja | Error overview. |

### 422: Validation error

| Feld | Typ | Pflicht | Beschreibung |
| --- | --- | --- | --- |
| `message` | string | ja | Errors overview. |
| `errors` | object | ja | A detailed description of each field that failed validation. |
