> For the complete documentation index, see [llms.txt](https://api-docs.everreal.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-docs.everreal.co/endpoints/candidates/candidate-mutation.md).

# Candidate Mutation

This mutation will add a candidate to a new listing. There is limited amount of information that you can add with a candidate.

{% hint style="warning" %}
Please keep in mind **GDPR**. Before you add a new [candidate](https://api-docs.everreal.co/key-concepts.md#candidate) in EverReal, make sure that the candidate accepted the terms and conditions of your [company](https://api-docs.everreal.co/key-concepts.md#company).
{% endhint %}

### Introduction

A candidate is a new prospect on a [listing](https://api-docs.everreal.co/key-concepts.md#listing).

When you add a candidate, EverReal does these things:

* It sends one of 3 emails to the candidate, unless you send `sendEmails: false` (see below):
  * a request for more information, if information is missing
  * a request to choose a time slot, if the listing invites candidates automatically and has free time slots
  * a thank-you email in all other cases
* It creates a [contact](https://api-docs.everreal.co/key-concepts.md#contact). The email address identifies the contact.
* It attaches the text of the `message` field to the candidate.
* It updates the candidate if you add the same candidate again.
* It sends no [webhook](https://api-docs.everreal.co/key-concepts.md#webhook). `LISTING_CANDIDATE_APPLIED` comes only if the candidate later sends the [full application form](https://api-docs.everreal.co/key-concepts.md#applicant-and-application-steps).

A new candidate needs these 4 parameters:

* the `listingId` you are adding the candidate to
* `email`
* `firstName`
* `lastName`

A blank `listingId`, a missing `email` or an email that is not valid fails at once with `BAD_USER_INPUT`. A `listingId` outside the company of the token fails at once with `validation.listing.does.not.exist`.

{% hint style="info" %}
**Addresses that EverReal does not mail.** Before a mail, EverReal checks the address against two lists. The first list holds addresses that bounced (the mail could not be delivered). The second list holds addresses with a spam complaint. EverReal sends no mail to an address on one of these lists. A bounced address leaves the list after one month. An address with a spam complaint stays on the list until the block is removed on request.
{% endhint %}

The **optional** parameters are:

```graphql
message: String
phoneNumber: String
desiredStartDate: Date
noTotalPeopleMovingIn: Int
netMonthlyIncomeRanges: IncomeRangeInput
currency: CURRENCY_TYPE
employmentType: CANDIDATE_EMPLOYMENT_TYPE
isFinancingReady: Boolean
isAnyoneSmoking: Boolean
hasPets: Boolean
hasEligibilityCertificate: Boolean
sendEmails: Boolean
```

### Mutation types

{% hint style="info" %}
A mutation changes data in GraphQL. The GraphQL documentation tells you more.
{% endhint %}

```graphql
type Mutation {
  upsertCandidateInitialApplication(
    listingId: String
    candidate: CandidateInitialApplicationRequest
    companyId: ID
  ): CandidateInitialApplicationResponse
}

input CandidateInitialApplicationRequest {
  firstName: String!
  lastName: String!
  email: String!
  message: String
  phoneNumber: String
  desiredStartDate: Date
  noTotalPeopleMovingIn: Int
  netMonthlyIncomeRanges: IncomeRangeInput
  currency: CURRENCY_TYPE
  employmentType: CANDIDATE_EMPLOYMENT_TYPE
  isFinancingReady: Boolean
  isAnyoneSmoking: Boolean
  hasPets: Boolean
  hasEligibilityCertificate: Boolean
  sendEmails: Boolean
}

type CandidateInitialApplicationResponse {
  success: Boolean
}

input IncomeRangeInput {
  from: Int!
  to: Int!
}

enum CURRENCY_TYPE {
  EUR
  USD
  GBP
  CHF
  DKK
  HRK
  HUF
  NOK
  SEK
  BGN
  CZK
  PLN
  RON
  AED
}

enum CANDIDATE_EMPLOYMENT_TYPE {
  EMPLOYED
  SELF_EMPLOYED
  STUDENT
  SEEKING_WORK
  CLERK
  RETIRED
  HOUSE_MAN_WIFE
  APPRENTICE
  POSTGRADUATE
  OTHER
}

```

`companyId` is optional. Use it to act in another company of your [partner](https://api-docs.everreal.co/key-concepts.md#partner) in which you are a [member](https://api-docs.everreal.co/key-concepts.md#user-and-member). Without it, the call acts in the company of your token. Another company answers `NOT_FOUND` with `companyScopedToken.notFoundForCompany`. See [Access model](https://api-docs.everreal.co/master/access-model.md).

### sendEmails

| Value   | What happens                                                                                                                                                                                              |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| not set | The candidate gets the automatic mails.                                                                                                                                                                   |
| `true`  | The same as not set.                                                                                                                                                                                      |
| `false` | EverReal sends no automatic mail to the candidate for this request. That means no confirmation, no "pick a slot" invitation, and no request for missing information. The notification to the admin stays. |

{% hint style="warning" %}
**Company workflows still run.** `sendEmails: false` stops only the automatic mails of EverReal. A company can also set up its own workflow (automation). Such a workflow starts at a new candidate or at an application. If the workflow has a "send email" step, the candidate gets that mail, also with `sendEmails: false`. To stop it, the company changes or turns off the workflow in the app.
{% endhint %}

### The creation is asynchronous

The call answers `{ "success": true }` as soon as it queues the creation. The candidate and the contact do not exist yet at that moment. They appear after some seconds. The listing can be one that you created a moment before.

To find the contact, use the `email` filter of `contacts`. If the list is empty, wait a short time and try again. See [Contact Query](https://api-docs.everreal.co/endpoints/contacts/contact-query.md) and [Guide: phone booking flow](https://api-docs.everreal.co/endpoints/calendar-and-viewings/guide-phone-booking-flow.md).

Example: create or update a candidate.

```graphql
mutation {
  upsertCandidateInitialApplication(
    listingId:"1eb2ad05-e692-4439-9ee9-2f61f3ff64bb",
    candidate:{
      email:"candidate@example.com"
      firstName:"Erika"
      lastName:"Example",
      message: "Hello, I would like to see the flat.",
      currency: EUR,
      phoneNumber: "+49123456",
      desiredStartDate: "2022-12-01",
      noTotalPeopleMovingIn: 3,
      netMonthlyIncomeRanges: {from: 3000, to: 4000},
      employmentType: CLERK
      sendEmails: false
    }
  ){ success }
} 

```
