> ## 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.

# Get Contact

> Retrieve a contact by ID or phone number

Get detailed information about a contact including their conversation history summary.

## Request Body

Provide either `contact_id` or `phone_number`:

<ParamField body="contact_id" type="string">
  The unique contact identifier.
</ParamField>

<ParamField body="phone_number" type="string">
  The contact's phone number in E.164 format.
</ParamField>

## Response

<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="metadata" type="object">
  Custom metadata.
</ResponseField>

<ResponseField name="stats" type="object">
  Conversation statistics:

  * `total_calls`: Number of calls
  * `total_messages`: Number of SMS messages
  * `last_contact`: Last interaction time
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.magpipe.ai/functions/v1/get-contact \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"phone_number": "+14155551234"}'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.magpipe.ai/functions/v1/get-contact',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        phone_number: '+14155551234'
      }),
    }
  );

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

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

  response = requests.post(
      'https://api.magpipe.ai/functions/v1/get-contact',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json',
      },
      json={'phone_number': '+14155551234'}
  )

  contact = response.json()
  print(f"Contact: {contact['name']}")
  ```
</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": "Prefers morning appointments",
    "tags": ["customer", "vip"],
    "metadata": {
      "customer_id": "cust_123"
    },
    "stats": {
      "total_calls": 5,
      "total_messages": 12,
      "last_contact": "2024-01-15T10:30:00Z"
    },
    "created_at": "2024-01-10T10:00:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
  ```
</ResponseExample>
