Contacts

List Contacts

GET /api/contacts/

Parameters

Parameter Name
Required
Type
Description

inbox

string

Deprecated: Use inboxes instead

inboxes

string

Conversation platform ID (used to filter contacts from a specific inbox)

page

integer

A page number within the paginated result set.

pageSize

integer

Number of results to return per page.

query

string

Search by name or source ID

search

string

Full-text search

Code Examples

# API Call Example (Shell)
curl -X GET "https://api.maiagent.ai/api/contacts/?inbox=550e8400-e29b-41d4-a716-446655440000&inboxes=example&page=1&pageSize=1&query=example&search=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.

Response Body

Status Code: 200

Response Schema Example

{
  "count": integer
  "next"?: string (uri) // Optional
  "previous"?: string (uri) // Optional
  "results": [
    {
      "id": string (uuid)
      "inboxes"?: [ // Optional
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "inbox"?:  // Backward compatibility field: single inbox, ignored if inboxes is also provided (Optional)
      {
        "id": string (uuid)
        "name": string
      }
      "name": string
      "avatar"?: string (uri) // Optional
      "phoneNumber"?: string // Optional
      "email"?: string (email) // Optional
      "sourceId"?: string // Optional
      "queryMetadata"?: object // Optional
      "mcpCredentials": string // List of the contact's MCP credentials
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}

Response Example Value

{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    [
      {
        "id": "user1_uuid",
        "inboxes": [
          {
            "id": "inbox_uuid",
            "name": "inbox_name"
          }
        ],
        "name": "user1",
        "avatar": "",
        "sourceId": null,
        "queryMetadata": null,
        "createdAt": "1751875361000",
        "updatedAt": "1751875361000"
      },
      {
        "id": "user2_uuid",
        "inboxes": [
          {
            "id": "inbox_uuid",
            "name": "inbox_name"
          }
        ],
        "name": "user2",
        "avatar": "avatar_url",
        "sourceId": "self defined source id",
        "queryMetadata": "self defined query metadata",
        "createdAt": "1751875400000",
        "updatedAt": "1751875400000"
      }
    ]
  ]
}

Create Contact

POST /api/contacts/

Code Example

# API Call Example (Shell)
curl -X POST "https://api.maiagent.ai/api/contacts/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inboxes": [
      {
        "id": "inbox_uuid"
      }
    ],
    "name": "user1",
    "avatar": "",
    "phoneNumber": 912345678,
    "email": "[email protected]",
    "sourceId": "self defined source id",
    "queryMetadata": "self defined query metadata"
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.

Response Body

Status Code: 201

Response Schema Example

{
  "id": string (uuid)
  "inboxes"?: [ // Optional
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "inbox"?:  // Backward compatibility field: single inbox, ignored if inboxes is also provided (Optional)
  {
    "id": string (uuid)
    "name": string
  }
  "name": string
  "avatar"?: string (uri) // Optional
  "phoneNumber"?: string // Optional
  "email"?: string (email) // Optional
  "sourceId"?: string // Optional
  "queryMetadata"?: object // Optional
  "mcpCredentials": string // List of the contact's MCP credentials
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}

Response Example Value

{
  "id": "user1_uuid",
  "inboxes": [
    {
      "id": "inbox_uuid",
      "name": "inbox_name"
    }
  ],
  "name": "user1",
  "avatar": "",
  "phoneNumber": 912345678,
  "email": "[email protected]",
  "sourceId": null,
  "queryMetadata": null,
  "createdAt": "1751875361000",
  "updatedAt": "1751875361000"
}

Get Contact Details

GET /api/contacts/{id}/

Parameters

Parameter Name
Required
Type
Description

id

string

A UUID string identifying this Contact.

Code Examples

# API Call Example (Shell)
curl -X GET "https://api.maiagent.ai/api/contacts/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.

Response Body

Status Code: 200

Response Schema Example

{
  "id": string (uuid)
  "inboxes"?: [ // Optional
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "inbox"?:  // Backward compatibility field: single inbox, ignored if inboxes is also provided (Optional)
  {
    "id": string (uuid)
    "name": string
  }
  "name": string
  "avatar"?: string (uri) // Optional
  "phoneNumber"?: string // Optional
  "email"?: string (email) // Optional
  "sourceId"?: string // Optional
  "queryMetadata"?: object // Optional
  "mcpCredentials": string // List of the contact's MCP credentials
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}

Response Example Value

{
  "id": "user1_uuid",
  "inboxes": [
    {
      "id": "inbox_uuid",
      "name": "inbox_name"
    }
  ],
  "name": "user1",
  "avatar": "",
  "phoneNumber": 912345678,
  "email": "[email protected]",
  "sourceId": null,
  "queryMetadata": null,
  "createdAt": "1751875361000",
  "updatedAt": "1751875361000"
}

Update Contact

PUT /api/contacts/{id}/

Parameters

Parameter Name
Required
Type
Description

id

string

A UUID string identifying this Contact.

Request Body

Request Parameters

Field
Type
Required
Description

name

string

No

Contact name

inboxes

array[object]

No

List of inboxes (new format)

inbox

object

No

Single inbox (old format, for backward compatibility)

inbox.id

string (uuid)

Yes

Inbox ID

avatar

string

No

Avatar URL

sourceId

string

No

Source ID

queryMetadata

string

No

Query metadata

Request Structure Example

{
  "name"?: string // Contact name (optional)
  "inboxes"?: [ // List of inboxes (new format) (optional)
    {
      "id": string (uuid) // Inbox ID
    }
  ]
  "inbox"?: { // Single inbox (old format, for backward compatibility) (optional)
  {
    "id": string (uuid) // Inbox ID
  }
  }
  "avatar"?: string // Avatar URL (optional)
  "sourceId"?: string // Source ID (optional)
  "queryMetadata"?: string // Query metadata (optional)
}

Request Example Value

{
  "inboxes": [
    {
      "id": "new_inbox_uuid"
    }
  ],
  "name": "updated_user_name",
  "avatar": "updated_avatar_url",
  "phoneNumber": 987654321,
  "email": "[email protected]",
  "sourceId": "updated_source_id",
  "queryMetadata": "updated_query_metadata"
}

Code Examples

# API Call Example (Shell)
curl -X PUT "https://api.maiagent.ai/api/contacts/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inboxes": [
      {
        "id": "new_inbox_uuid"
      }
    ],
    "name": "updated_user_name",
    "avatar": "updated_avatar_url",
    "phoneNumber": 987654321,
    "email": "[email protected]",
    "sourceId": "updated_source_id",
    "queryMetadata": "updated_query_metadata"
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.

Response Body

Status Code: 200

Response Schema Example

{
  "id": string (uuid)
  "inboxes"?: [ // Optional
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "inbox"?:  // Backward compatibility field: single inbox, ignored if inboxes is also provided (Optional)
  {
    "id": string (uuid)
    "name": string
  }
  "name": string
  "avatar"?: string (uri) // Optional
  "phoneNumber"?: string // Optional
  "email"?: string (email) // Optional
  "sourceId"?: string // Optional
  "queryMetadata"?: object // Optional
  "mcpCredentials": string // List of the contact's MCP credentials
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}

Response Example Value

{
  "id": "user1_uuid",
  "inboxes": [
    {
      "id": "inbox_uuid",
      "name": "inbox_name"
    }
  ],
  "name": "user1",
  "avatar": "",
  "phoneNumber": 912345678,
  "email": "[email protected]",
  "sourceId": null,
  "queryMetadata": null,
  "createdAt": "1751875361000",
  "updatedAt": "1751875361000"
}

Update Contact

PATCH /api/contacts/{id}/

Parameters

Parameter Name
Required
Type
Description

id

string

A UUID string identifying this Contact.

Request Body

Request Parameters

Field
Type
Required
Description

name

string

No

Contact name

inboxes

array[object]

No

List of inboxes (new format)

inbox

object

No

Single inbox (old format, for backward compatibility)

inbox.id

string (uuid)

Yes

Inbox ID

avatar

string

No

Avatar URL

sourceId

string

No

Source ID

queryMetadata

string

No

Query metadata

Request Structure Example

{
  "name"?: string // Contact name (optional)
  "inboxes"?: [ // List of inboxes (new format) (optional)
    {
      "id": string (uuid) // Inbox ID
    }
  ]
  "inbox"?: { // Single inbox (old format, for backward compatibility) (optional)
  {
    "id": string (uuid) // Inbox ID
  }
  }
  "avatar"?: string // Avatar URL (optional)
  "sourceId"?: string // Source ID (optional)
  "queryMetadata"?: string // Query metadata (optional)
}

Request Example Value

{
  "inboxes": [
    {
      "id": "new_inbox_uuid"
    }
  ],
  "name": "updated_user_name",
  "avatar": "updated_avatar_url",
  "phoneNumber": 987654321,
  "email": "[email protected]",
  "sourceId": "updated_source_id",
  "queryMetadata": "updated_query_metadata"
}

Code Examples

# API Call Example (Shell)
curl -X PATCH "https://api.maiagent.ai/api/contacts/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inboxes": [
      {
        "id": "new_inbox_uuid"
      }
    ],
    "name": "updated_user_name",
    "avatar": "updated_avatar_url",
    "phoneNumber": 987654321,
    "email": "[email protected]",
    "sourceId": "updated_source_id",
    "queryMetadata": "updated_query_metadata"
  }'

# Please replace YOUR_API_KEY and verify the request data before execution.

Response Body

Status Code: 200

Response Schema Example

{
  "id": string (uuid)
  "inboxes"?: [ // Optional
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "inbox"?:  // Backward compatibility field: single inbox, ignored if inboxes is also provided (Optional)
  {
    "id": string (uuid)
    "name": string
  }
  "name": string
  "avatar"?: string (uri) // Optional
  "phoneNumber"?: string // Optional
  "email"?: string (email) // Optional
  "sourceId"?: string // Optional
  "queryMetadata"?: object // Optional
  "mcpCredentials": string // List of the contact's MCP credentials
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}

Response Example Value

{
  "id": "user1_uuid",
  "inboxes": [
    {
      "id": "inbox_uuid",
      "name": "inbox_name"
    }
  ],
  "name": "user1",
  "avatar": "",
  "phoneNumber": 912345678,
  "email": "[email protected]",
  "sourceId": null,
  "queryMetadata": null,
  "createdAt": "1751875361000",
  "updatedAt": "1751875361000"
}

Delete Contact

DELETE /api/contacts/{id}/

Parameters

Parameter Name
Required
Type
Description

id

string

A UUID string identifying this Contact.

Code Examples

# API Call Example (Shell)
curl -X DELETE "https://api.maiagent.ai/api/contacts/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Please replace YOUR_API_KEY and verify the request data before execution.

Response

Status Code
Description

204

No response body

400

The contact still has associated conversations and cannot be deleted


Last updated

Was this helpful?