## Variables

### entity_id

| Field         | Type  | Description                                                                 |
|---------------|-------|-----------------------------------------------------------------------------|
| entity_id     | UUID  | The unique identifier for the entity to which the representative is being added. |

### representative

| Field                               | Type        | Description                                                                                                                            |
|-------------------------------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------|
| document_expiration_date            | DateTime   | The expiration date of the representative's identification document.                                                                    |
| document_issue_date                 | DateTime   | The issue date of the representative's identification document.                                                                        |
| document_number                     | String     | The number of the representative's identification document.                                                                           |
| citizenship                         | String     | The country of citizenship of the representative.                                                                                     |
| date_of_birth                       | DateTime   | The date of birth of the representative.                                                                                              |
| email                                | String     | The email address of the representative.                                                                                              |
| first_name                          | String     | The first name of the representative.                                                                                                 |
| is_signer                           | Boolean    | Indicates if the representative is a signer for the entity.                                                                          |
| last_name                           | String     | The last name of the representative.                                                                                                  |
| job_title                           | String     | The job title of the representative within the entity.                                                                               |
| ownership_percentage                | Float      | The percentage of ownership the representative has in the entity.                                                                    |
| passport_number                     | String     | The passport number of the representative, if applicable.                                                                            |
| phone                               | String     | The phone number of the representative.                                                                                                |
| residential_address                 | String     | The primary residential address of the representative.                                                                               |
| residential_address2                | String     | The secondary residential address of the representative (optional).                                                                   |
| residential_city                    | String     | The city of the representative's residential address.                                                                                |
| residential_country                 | String     | The country of the representative's residential address.                                                                             |
| residential_postal_code             | String     | The postal code of the representative's residential address.                                                                         |
| residential_state_province_region    | String     | The state, province, or region of the representative's residential address.                                                           |
| responsibility                       | String     | The responsibility of the representative within the entity. Can be one of:                                                            |
|                                     |             | - `ultimate_beneficial_owner`                                                                                                       |
|                                     |             | - `authorized rep`                                                                                                                   |
|                                     |             | - `director`                                                                                                                          |
| tax_number                          | String     | The tax identification number of the representative e.g. SSN for US citizens.                                                       |

### Query

string

Defaults to {}

### Response examples

#### Success (200)

```json
{
  "data": {
    "createRepresentative": "573442c4-e010-480b-9acf-861fac940e9a"
  }
}
```

#### Error (400)

```json
{
  "errors": [
    {
      "message": "Invalid request syntax"
    }
  ]
}
```

### Example Code

```javascript
const axios = require('axios');

const token = process.env.RF_KEY;

let data = JSON.stringify({
  query: `mutation createRepresentative (
    $entity_id: UUID
    $representative: RepresentativeInput
) {
    createRepresentative (
        entity_id: $entity_id
        representative: $representative
    )
}`,
  variables: {
    entity_id: "YOUR_ENTITY_ID",
    representative: {
      document_expiration_date: '1990-09-26T00:00:00Z',
      document_issue_date: '2020-10-28T00:00:00Z',
      document_number: '9078092879078320978',
      citizenship: "USA",
      date_of_birth: "1990-09-26T00:00:00Z",
      email: 'meow@meow.com',
      first_name: "John",
      is_signer: true,
      last_name: "Smith",
      job_title: "CEO",
      ownership_percentage: 100,
      passport_number: null,
      phone: '2813308004',
      residential_address: '1305 e 6th street',
      residential_address2: null,
      residential_city: "Austin",
      residential_country: "USA",
      residential_postal_code: '78733',
      residential_state_province_region: "TX",
      responsibility: "ultimate_beneficial_owner",
      tax_number: '12123222'
    }
  }
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://sandbox.external.routefusion.com/graphql',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${token}`
  },
  data: data
};

axios.request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data, null, 2));
  })
  .catch((error) => {
    console.error(error.response ? error.response.data : error.message);
  });
```
