> ## Documentation Index
> Fetch the complete documentation index at: https://docs.emailbison.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Variables

A custom variable is EmailBisons way of attaching any extra information to a lead.

Custom Variables need to be created before they can be attached to leads with a custom value for each lead.

<Note>Note: custom variables are unique per workspace</Note>

## Creating Custom Variables

<Tabs>
  <Tab title="API" icon="binary">
    You can create a custom variable by submitting a `POST` request at the [following endpoint](https://dedi.emailbison.com/api/reference#tag/custom-lead-variables/post/api/custom-variables).

    ```bash theme={null}
    /api/custom-variables
    ```

    The only field you can and must provide is `name`, which is a name for the custom variable.
  </Tab>
</Tabs>

## Attaching Custom Variables to Leads

<Tabs>
  <Tab title="API" icon="binary">
    When you are creating or updating a lead - either with a `POST` or a `PUT` - you can pass the `custom_variables` field as an array of objects that contain a `name` key and a `value` key. The JSON will look like the following.

    ```json theme={null}
    "custom_variables": [
        {
      	  "name": "phone_number",
      	  "value": "123-456-7890"
    	},
        {
    	  "name": "priority",
    	  "value": "super-high"
        }
      ]
    ```

    <Note>Note how the everything is wrapped in an array identifier `[]`, and each custom variable is wrapped in an object identifier `{}`</Note>

    An example of adding custom variables when updating leads:

    <CodeGroup>
      ```Bash curl {9-14} theme={null}
      curl https://dedi.emailbison.com/api/leads \
        --request PUT \
        --header 'Content-Type: application/json' \
        --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
        --data '{
        "first_name": "John",
        "last_name": "Doe",
        "email": "john@doe.com",
        "custom_variables": [
      	{
      	  "name": "phone number",
      	  "value": "9059999999"
      	}
        ]
      }'
      ```

      ```JavaScript JavaScript {11-14} theme={null}
      fetch('https://dedi.emailbison.com/api/leads/{lead_id}', {
        method: 'PUT',
        headers: {
      	'Content-Type': 'application/json',
      	Authorization: 'Bearer YOUR_SECRET_TOKEN'
        },
        body: JSON.stringify({
      	first_name: 'John',
      	last_name: 'Doe',
      	email: 'john@doe.com',
      	custom_variables: [{
      	  name: 'phone number',
      	  value: '9059999999'
      	}]
        })
      })
      ```

      ```Python Python {10-15} theme={null}
      headers = {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer YOUR_SECRET_TOKEN',
      }

      json_data = {
      	'first_name': 'John',
      	'last_name': 'Doe',
      	'email': 'john@doe.com',
      	'custom_variables': [
      		{
      			'name': 'phone number',
      			'value': '9059999999',
      		},
      	],
      }

      response = requests.put('https://dedi.emailbison.com/api/leads/{lead_id}', headers=headers, json=json_data)
      ```
    </CodeGroup>
  </Tab>

  <Tab title="UI" icon="browser">
    Refer to [Leads](/leads/creating-a-lead#ui) on uploading a CSV using the UI.

    1. Include Custom Variables as columns in the CSV.
           <img src="https://mintcdn.com/emailbison-306cc08e/6vP4IPDHlIEu3rWW/images/custom-var-csv.png?fit=max&auto=format&n=6vP4IPDHlIEu3rWW&q=85&s=4dc79d6c9825ce6c1e3984298a842dc1" alt="an example of two custom variables, interests and phone_number" width="1399" height="235" data-path="images/custom-var-csv.png" />

    2. Once you upload the CSV, the UI will ask you to map your headers.<br />
       During this step, click on `Add custom variable`, enter a name for your variable and click the `+` button.
           <img src="https://mintcdn.com/emailbison-306cc08e/6vP4IPDHlIEu3rWW/images/creating-custom-var.png?fit=max&auto=format&n=6vP4IPDHlIEu3rWW&q=85&s=69b25b4a87757895ae956ad9343e9d57" alt="Creating Custom Variables" width="711" height="659" data-path="images/creating-custom-var.png" />

    3. After following the first and seconds steps, map your custom variables to the CSV headers.<br />
       For example, map the `phone number` custom variable to the `phone_number` CSV header.
           <img src="https://mintcdn.com/emailbison-306cc08e/6vP4IPDHlIEu3rWW/images/mapping-custom-vars.png?fit=max&auto=format&n=6vP4IPDHlIEu3rWW&q=85&s=00d7e34c85cf45e16056080dda8d9e66" alt="Mapping Custom Variables" width="711" height="802" data-path="images/mapping-custom-vars.png" />
  </Tab>
</Tabs>
