Contacts API

Contact attributes

Name Type Description
id integer  
contact_id integer  
label string  
first_name string  
last_name string  
organization_name string  
job_title string  
address1 string  
address2 string  
city string  
state_province string  
postal_code string  
country string The ISO Alpha-2 country code.
phone string  
fax string  
email string  
created_at datetime  
updated_at datetime  

List contacts

GET /:account/contacts

List contacts in the account.

Parameters

Name Type Description
:account integer The account id

Example

List all contacts in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      https://api.dnsimple.com/v2/1010/contacts

Response

Responds with HTTP 200.

{
  "data": [
    {
      "id": 1,
      "account_id": 1010,
      "label": "Default",
      "first_name": "First",
      "last_name": "User",
      "job_title": "CEO",
      "organization_name": "Awesome Company",
      "email": "first@example.com",
      "phone": "+18001234567",
      "fax": "+18011234567",
      "address1": "Italian Street, 10",
      "address2": "",
      "city": "Roma",
      "state_province": "RM",
      "postal_code": "00100",
      "country": "IT",
      "created_at": "2013-11-08T17:23:15Z",
      "updated_at": "2015-01-08T21:30:50Z"
    },
    {
      "id": 2,
      "account_id": 1010,
      "label": "",
      "first_name": "Second",
      "last_name": "User",
      "job_title": "",
      "organization_name": "",
      "email": "second@example.com",
      "phone": "+18881234567",
      "fax": "",
      "address1": "French Street",
      "address2": "c/o Someone",
      "city": "Paris",
      "state_province": "XY",
      "postal_code": "00200",
      "country": "FR",
      "created_at": "2014-12-06T15:46:18Z",
      "updated_at": "2014-12-06T15:46:18Z"
    }
  ],
  "pagination": {
    "current_page": 1,
    "per_page": 30,
    "total_entries": 2,
    "total_pages": 1
  }
}

Sorting

For general information about sorting, please refer to the main guide.

Name Description
id Sort contacts by ID
label Sort contacts by label (alphabetical order)
email Sort contacts by email (alphabetical order)

The default sorting policy is by ascending id.

Create a contact

POST /:account/contacts

Parameters

Name Type Description
:account integer The account id

Example

Create a contact in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X POST \
      -d '<json>' \
      https://api.dnsimple.com/v2/1010/contacts

Input

Name Type Description
label string  
first_name string Required.
last_name string Required.
organization_name string The company name. If the organization_name is specified, then you must also include job_title.
job_title string  
address1 string Required.
address2 string  
city string Required.
state_province string Required.
postal_code string Required.
country string Required.
email string Required.
phone string Required.
fax string Required.
Example
{
  "label": "Default",
  "first_name": "First",
  "last_name": "User",
  "job_title": "CEO",
  "organization_name": "Awesome Company",
  "email": "first@example.com",
  "phone": "+18001234567",
  "fax": "+18011234567",
  "address1": "Italian Street, 10",
  "city": "Roma",
  "state_province": "RM",
  "postal_code": "00100",
  "country": "IT"
}

Response

Responds with HTTP 201 on success.

{
  "data": {
    "id": 1,
    "account_id": 1010,
    "label": "Default",
    "first_name": "First",
    "last_name": "User",
    "job_title": "CEO",
    "organization_name": "Awesome Company",
    "email": "first@example.com",
    "phone": "+18001234567",
    "fax": "+18011234567",
    "address1": "Italian Street, 10",
    "address2": "",
    "city": "Roma",
    "state_province": "RM",
    "postal_code": "00100",
    "country": "IT",
    "created_at": "2016-01-19T20:50:26Z",
    "updated_at": "2016-01-19T20:50:26Z"
  }
}

Responds with HTTP 400 if the validation fails.

Get a contact

GET /:account/contacts/:contact

Parameters

Name Type Description
:account integer The account id
:contact integer The contact id

Example

Get the contact with ID 1 in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      https://api.dnsimple.com/v2/1010/contacts/1

Response

{
  "data": {
    "id": 1,
    "account_id": 1010,
    "label": "Default",
    "first_name": "First",
    "last_name": "User",
    "job_title": "CEO",
    "organization_name": "Awesome Company",
    "email": "first@example.com",
    "phone": "+18001234567",
    "fax": "+18011234567",
    "address1": "Italian Street, 10",
    "address2": "",
    "city": "Roma",
    "state_province": "RM",
    "postal_code": "00100",
    "country": "IT",
    "created_at": "2016-01-19T20:50:26Z",
    "updated_at": "2016-01-19T20:50:26Z"
  }
}

Update a contact

PATCH /:account/contacts/:contact

Parameters

Name Type Description
:account integer The account id
:contact integer The contact id

Example

Update the contact with ID 1 in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X PATCH \
      -d '<json>' \
      https://api.dnsimple.com/v2/1010/contacts/1

Input

See create.

Response

Responds with HTTP 200 on success.

{
  "data": {
    "id": 1,
    "account_id": 1010,
    "label": "Default",
    "first_name": "First",
    "last_name": "User",
    "job_title": "CEO",
    "organization_name": "Awesome Company",
    "email": "first@example.com",
    "phone": "+18001234567",
    "fax": "+18011234567",
    "address1": "Italian Street, 10",
    "address2": "",
    "city": "Roma",
    "state_province": "RM",
    "postal_code": "00100",
    "country": "IT",
    "created_at": "2016-01-19T20:50:26Z",
    "updated_at": "2016-01-19T20:50:26Z"
  }
}

Responds with HTTP 400 if the validation fails.

Delete a contact

DELETE /:account/contacts/:contact

Parameters

Name Type Description
:account integer The account id
:contact integer The contact id

Example

Delete the contact with ID 1 in the account 1010:

curl  -H 'Authorization: Bearer <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X DELETE \
      https://api.dnsimple.com/v2/1010/contacts/1

Response

Responds with HTTP 204 on success.

Responds with HTTP 400 if the contact cannot be deleted because it’s currently used by a domain or a certificate.

{
  "message": "The contact cannot be deleted because it's currently in use"
}