Skip to content

/admin/addresses/:id/contacts

Path: /admin/addresses/:id/contacts

Namespace: admin

Parent Resource: addresses

Overview

Contacts represent contact persons associated with an address. Each contact contains name, email, phone, and role information.

Available Operations

List Contacts (GET)

Endpoint: GET /admin/addresses/:id/contacts.json

Description: Retrieve all contacts for a specific address.

Request Example:

bash
GET /admin/addresses/123/contacts.json

Response (200 OK):

json
{
  "contacts": [
    {
      "id": 1,
      "address_id": 123,
      "name": "John Doe",
      "email": "[email protected]",
      "phone": "+1234567890",
      "role": "Manager"
    }
  ]
}

Show Contact (GET /:id)

Endpoint: GET /admin/addresses/:id/contacts/:id.json

Description: Retrieve a specific contact.

Request Example:

bash
GET /admin/addresses/123/contacts/1.json

Response (200 OK):

json
{
  "contact": {
    "id": 1,
    "address_id": 123,
    "name": "John Doe",
    "email": "[email protected]",
    "phone": "+1234567890",
    "role": "Manager"
  }
}

Create Contact (POST)

Endpoint: POST /admin/addresses/:id/contacts.json

Description: Create a new contact for an address.

Request Example:

bash
POST /admin/addresses/123/contacts.json
Content-Type: application/json

{
  "contact": {
    "name": "Jane Smith",
    "email": "[email protected]",
    "phone": "+1234567891",
    "role": "Accountant"
  }
}

Response (201 Created):

json
{
  "contact": {
    "id": 2,
    "address_id": 123,
    "name": "Jane Smith",
    "email": "[email protected]"
  }
}

Update Contact (PATCH /:id)

Endpoint: PATCH /admin/addresses/:id/contacts/:id.json

Description: Update an existing contact.

Request Example:

bash
PATCH /admin/addresses/123/contacts/1.json
Content-Type: application/json

{
  "contact": {
    "email": "[email protected]"
  }
}

Response (200 OK):

json
{
  "contact": {
    "id": 1,
    "email": "[email protected]"
  }
}

Delete Contact (DELETE /:id)

Endpoint: DELETE /admin/addresses/:id/contacts/:id.json

Description: Delete a contact.

Request Example:

bash
DELETE /admin/addresses/123/contacts/1.json

Response (204 No Content)

Batch Actions (POST /batch_action)

Endpoint: POST /admin/addresses/:id/contacts/batch_action.json

Description: Perform batch operations on selected contacts.

Request Example:

bash
POST /admin/addresses/123/contacts/batch_action.json
Content-Type: application/json

{
  "batch_action": "update",
  "collection_selection": [1, 2, 3],
  "batch_action_inputs": {
    "role": "Manager"
  }
}

Response (200 OK):

json
{
  "message": "Batch action completed",
  "affected_count": 3
}

Released under an open source license.