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

# Create Contact

> Create a new contact in your address book

Create a new contact for managing caller information and conversation history.

## Request Body

<ParamField body="phone_number" type="string" required>
  Contact's phone number in E.164 format.

  **Example:** `+14155551234`
</ParamField>

<ParamField body="name" type="string">
  Contact's full name.

  **Example:** `John Smith`
</ParamField>

<ParamField body="email" type="string">
  Contact's email address.

  **Example:** `john@example.com`
</ParamField>

<ParamField body="company" type="string">
  Contact's company or organization.

  **Example:** `Acme Corp`
</ParamField>

<ParamField body="notes" type="string">
  Internal notes about the contact.

  **Example:** `Prefers morning appointments`
</ParamField>

<ParamField body="tags" type="array">
  Array of tags for categorization.

  **Example:** `["customer", "vip"]`
</ParamField>

<ParamField body="metadata" type="object">
  Custom key-value pairs for your reference.

  ```json theme={null}
  {
    "customer_id": "cust_123",
    "source": "website"
  }
  ```
</ParamField>

## Response

Returns the created contact object.

<ResponseField name="id" type="string">
  Unique contact identifier.
</ResponseField>

<ResponseField name="phone_number" type="string">
  Contact's phone number.
</ResponseField>

<ResponseField name="name" type="string">
  Contact's name.
</ResponseField>

<ResponseField name="email" type="string">
  Contact's email.
</ResponseField>

<ResponseField name="company" type="string">
  Contact's company.
</ResponseField>

<ResponseField name="notes" type="string">
  Internal notes.
</ResponseField>

<ResponseField name="tags" type="array">
  Contact tags.
</ResponseField>

<ResponseField name="created_at" type="string">
  When the contact was created.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.magpipe.ai/functions/v1/create-contact \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "phone_number": "+14155551234",
      "name": "John Smith",
      "email": "john@example.com",
      "company": "Acme Corp",
      "tags": ["customer", "vip"]
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.magpipe.ai/functions/v1/create-contact',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        phone_number: '+14155551234',
        name: 'John Smith',
        email: 'john@example.com',
        company: 'Acme Corp',
        tags: ['customer', 'vip']
      }),
    }
  );

  const contact = await response.json();
  console.log('Created:', contact.id);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.magpipe.ai/functions/v1/create-contact',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json',
      },
      json={
          'phone_number': '+14155551234',
          'name': 'John Smith',
          'email': 'john@example.com',
          'company': 'Acme Corp',
          'tags': ['customer', 'vip']
      }
  )

  contact = response.json()
  print(f"Created: {contact['id']}")
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "id": "c1d2e3f4-5678-9abc-def0-123456789abc",
    "phone_number": "+14155551234",
    "name": "John Smith",
    "email": "john@example.com",
    "company": "Acme Corp",
    "notes": null,
    "tags": ["customer", "vip"],
    "metadata": {},
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
  ```

  ```json Error Response theme={null}
  {
    "error": {
      "code": "duplicate_contact",
      "message": "A contact with this phone number already exists"
    }
  }
  ```
</ResponseExample>
