Saltar al contenido principal
GET
https://api.contactship.ai
/
v1
/
contacts
/
{phoneNumber}
/
call-history
# Get call history for a contact by phone number
curl -X GET "https://api.contactship.ai/v1/contacts/+573014445709/call-history" \
  -H "x-api-key: your-api-key"
{
  "statusCode": 200,
  "data": {
    "contact_id": "c8a23f45-9b12-4d78-af90-1e5d23c67890",
    "contact": {
      "full_name": "Maria González",
      "country": "México",
      "email": "maria.gonzalez@ejemplo.com",
      "phone_number": "+525512345678",
      "additional_data": null,
      "description": "Lead from Facebook campaign",
      "created_at": "2024-03-01T15:30:00.123+00:00"
    },
    "history": {
      "call_attempts": 2,
      "calls": [
        {
          "direction": "outbound-api",
          "from": "+525619190379",
          "call_record": "https://storage.example.com/recordings/abc123def456/recording.wav",
          "status": "answered",
          "start_at": "2024-03-05T14:20:15.445+00:00",
          "finished_at": "2024-03-05T14:23:45.571+00:00",
          "price": 15,
          "price_unit": "USD",
          "duration": "210",
          "call_analysis": {
            "call_summary": "Cliente mostró interés en el producto premium. Solicitó información sobre precios y características específicas.",
            "in_voicemail": false,
            "user_sentiment": "Positive",
            "call_successful": true,
            "custom_analysis_data": {
              "email_usuario": "maria.gonzalez@ejemplo.com",
              "canal_de_seguimiento": "email",
              "quiere_mas_informacion": true
            }
          },
          "type": "api_call",
          "created_at": "2024-03-05T14:20:00.123456+00:00",
          "chat_history": [
            {
              "role": "assistant",
              "content": "¡Hola! Le llamo de parte de nuestra empresa para hablar sobre nuestros servicios premium."
            },
            {
              "role": "user",
              "content": "Me interesa conocer más sobre los precios y características."
            }
          ]
        },
        {
          "direction": "outbound-api",
          "from": "+525619190379",
          "call_record": "https://storage.example.com/recordings/xyz789uvw/recording.wav",
          "status": "voicemail",
          "start_at": "2024-03-01T16:00:00.445+00:00",
          "finished_at": "2024-03-01T16:00:45.571+00:00",
          "price": 5,
          "price_unit": "USD",
          "duration": "45",
          "call_analysis": {
            "call_summary": "Llamada dirigida a buzón de voz. Se dejó mensaje con información de contacto.",
            "in_voicemail": true,
            "user_sentiment": "Neutral",
            "call_successful": true,
            "custom_analysis_data": {
              "email_usuario": "",
              "canal_de_seguimiento": "phone",
              "quiere_mas_informacion": false
            }
          },
          "type": "api_call",
          "created_at": "2024-03-01T16:00:00.123456+00:00",
          "chat_history": [
            {
              "role": "assistant",
              "content": "Le dejamos un mensaje en su buzón de voz con nuestra información de contacto."
            }
          ]
        }
      ],
      "last_call": {
        "direction": "outbound-api",
        "from": "+525619190379",
        "call_record": "https://storage.example.com/recordings/abc123def456/recording.wav",
        "status": "answered",
        "start_at": "2024-03-05T14:20:15.445+00:00",
        "finished_at": "2024-03-05T14:23:45.571+00:00",
        "price": 15,
        "price_unit": "USD",
        "duration": "210",
        "call_analysis": {
          "call_summary": "Cliente mostró interés en el producto premium. Solicitó información sobre precios y características específicas.",
          "in_voicemail": false,
          "user_sentiment": "Positive",
          "call_successful": true,
          "custom_analysis_data": {
            "email_usuario": "maria.gonzalez@ejemplo.com",
            "canal_de_seguimiento": "email",
            "quiere_mas_informacion": true
          }
        },
        "type": "api_call",
        "created_at": "2024-03-05T14:20:00.123456+00:00",
        "chat_history": [
          {
            "role": "assistant",
            "content": "¡Hola! Le llamo de parte de nuestra empresa para hablar sobre nuestros servicios premium."
          },
          {
            "role": "user",
            "content": "Me interesa conocer más sobre los precios y características."
          }
        ]
      }
    }
  }
}
This endpoint allows you to retrieve the complete call history for a contact using their phone number. This is useful when you don’t have the contact’s ID but need to quickly access their call history.

Use Cases

  • Review call history with a contact using just their phone number
  • Track communication history for incoming calls from unknown numbers
  • Quick lookup of call records during customer service interactions
  • Verify previous interactions with a phone number

Path Parameters

phoneNumber
string
requerido
The phone number of the contact in international format (e.g., +12124567890)

Headers

x-api-key
string
requerido
Your API key for authentication. You can find this in your dashboard under API settings.

Query Parameters

start_date
string
Filter calls that occurred on or after this date (ISO 8601 format, e.g., 2023-01-01). If not specified, returns all calls from the beginning.
end_date
string
Filter calls that occurred on or before this date (ISO 8601 format, e.g., 2023-12-31). If not specified, returns all calls up to the current date.
direction
string
Filter calls by direction. Possible values: inbound, outbound. If not specified, returns both inbound and outbound calls.
status
string
Filter calls by status. Possible values: answered, missed, rejected, busy, failed. If not specified, returns calls with any status.

Response

status code
number
200 on success
contact
object
Information about the contact
call_history
object
The call history for the contact

Error Codes

  • 400 Bad Request - Invalid phone number format
  • 401 Unauthorized - Invalid or missing API key
  • 404 Not Found - Contact not found
  • 500 Internal Server Error - Server-side error

Code Examples

# Get call history for a contact by phone number
curl -X GET "https://api.contactship.ai/v1/contacts/+573014445709/call-history" \
  -H "x-api-key: your-api-key"
{
  "statusCode": 200,
  "data": {
    "contact_id": "c8a23f45-9b12-4d78-af90-1e5d23c67890",
    "contact": {
      "full_name": "Maria González",
      "country": "México",
      "email": "maria.gonzalez@ejemplo.com",
      "phone_number": "+525512345678",
      "additional_data": null,
      "description": "Lead from Facebook campaign",
      "created_at": "2024-03-01T15:30:00.123+00:00"
    },
    "history": {
      "call_attempts": 2,
      "calls": [
        {
          "direction": "outbound-api",
          "from": "+525619190379",
          "call_record": "https://storage.example.com/recordings/abc123def456/recording.wav",
          "status": "answered",
          "start_at": "2024-03-05T14:20:15.445+00:00",
          "finished_at": "2024-03-05T14:23:45.571+00:00",
          "price": 15,
          "price_unit": "USD",
          "duration": "210",
          "call_analysis": {
            "call_summary": "Cliente mostró interés en el producto premium. Solicitó información sobre precios y características específicas.",
            "in_voicemail": false,
            "user_sentiment": "Positive",
            "call_successful": true,
            "custom_analysis_data": {
              "email_usuario": "maria.gonzalez@ejemplo.com",
              "canal_de_seguimiento": "email",
              "quiere_mas_informacion": true
            }
          },
          "type": "api_call",
          "created_at": "2024-03-05T14:20:00.123456+00:00",
          "chat_history": [
            {
              "role": "assistant",
              "content": "¡Hola! Le llamo de parte de nuestra empresa para hablar sobre nuestros servicios premium."
            },
            {
              "role": "user",
              "content": "Me interesa conocer más sobre los precios y características."
            }
          ]
        },
        {
          "direction": "outbound-api",
          "from": "+525619190379",
          "call_record": "https://storage.example.com/recordings/xyz789uvw/recording.wav",
          "status": "voicemail",
          "start_at": "2024-03-01T16:00:00.445+00:00",
          "finished_at": "2024-03-01T16:00:45.571+00:00",
          "price": 5,
          "price_unit": "USD",
          "duration": "45",
          "call_analysis": {
            "call_summary": "Llamada dirigida a buzón de voz. Se dejó mensaje con información de contacto.",
            "in_voicemail": true,
            "user_sentiment": "Neutral",
            "call_successful": true,
            "custom_analysis_data": {
              "email_usuario": "",
              "canal_de_seguimiento": "phone",
              "quiere_mas_informacion": false
            }
          },
          "type": "api_call",
          "created_at": "2024-03-01T16:00:00.123456+00:00",
          "chat_history": [
            {
              "role": "assistant",
              "content": "Le dejamos un mensaje en su buzón de voz con nuestra información de contacto."
            }
          ]
        }
      ],
      "last_call": {
        "direction": "outbound-api",
        "from": "+525619190379",
        "call_record": "https://storage.example.com/recordings/abc123def456/recording.wav",
        "status": "answered",
        "start_at": "2024-03-05T14:20:15.445+00:00",
        "finished_at": "2024-03-05T14:23:45.571+00:00",
        "price": 15,
        "price_unit": "USD",
        "duration": "210",
        "call_analysis": {
          "call_summary": "Cliente mostró interés en el producto premium. Solicitó información sobre precios y características específicas.",
          "in_voicemail": false,
          "user_sentiment": "Positive",
          "call_successful": true,
          "custom_analysis_data": {
            "email_usuario": "maria.gonzalez@ejemplo.com",
            "canal_de_seguimiento": "email",
            "quiere_mas_informacion": true
          }
        },
        "type": "api_call",
        "created_at": "2024-03-05T14:20:00.123456+00:00",
        "chat_history": [
          {
            "role": "assistant",
            "content": "¡Hola! Le llamo de parte de nuestra empresa para hablar sobre nuestros servicios premium."
          },
          {
            "role": "user",
            "content": "Me interesa conocer más sobre los precios y características."
          }
        ]
      }
    }
  }
}

Notes and Best Practices

  • Always use international format for phone numbers (e.g., +12124567890)
  • URL encode the phone number in the request URL to handle special characters
  • Use date filtering to narrow down results for contacts with extensive call histories
  • Consider implementing caching for frequently accessed call histories
  • Monitor call durations and frequencies to optimize customer engagement strategies