> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quickblox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload Address Book

> Upload address book contacts.

#### Recipes

> [accordion] Delete contact
>
> **1. 1. Use a `contacts` parameter to set an array of contact hashes**
>
> ```curl {5} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Ann",
>       "phone": "11223334237",
>       "destroy": 1
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **2. 2. Set a name of the contact**
>
> Note that a name is limited to a number of signs. Min: **1**. Max: **25**.
>
> ```curl {7} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Ann",
>       "phone": "11223334237",
>       "destroy": 1
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **3. 3. Set a phone of the contact**
>
> Note that a phone is limited to a number of signs. Min: **10**. Max: **15**.
>
> ```curl {8} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Ann",
>       "phone": "11223334237",
>       "destroy": 1
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **4. 4. Specify if you want to delete a contact**
>
> Set a `destroy` parameter as `1` to delete a contact.
>
> ```curl {9} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Ann",
>       "phone": "11223334237",
>       "destroy": 1
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **5. 5. Set a device identifier**
>
> Set a `udid` parameter to specify a user's device. If specified, a contact will be deleted for a specified device only.
>
> ```curl {12} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Ann",
>       "phone": "11223334237",
>       "destroy": 1
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **6. 6. As a result, the API returns a response specifying that a contact was deleted.**
>
> ```curl theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Ann",
>       "phone": "11223334237",
>       "destroy": 1
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```

> [accordion] Upload address book with incorrect data
>
> **1. 1. Use a `contacts` parameter to set an array of contact hashes**
>
> ```curl {5} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Alex"
>     },
>     {
>       "phone": "45645645666"
>     },
>     {
>       "name": "",
>       "phone": "456456456"
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **2. 2. Set a `name` and `phone` of the contact as separate arrays**
>
> Note that it's incorrect to set a `name` separately from a `phone`.
>
> ```curl {7, 10} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Alex"
>     },
>     {
>       "phone": "45645645666"
>     },
>     {
>       "name": "",
>       "phone": "456456456"
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **3. 3. Set a `name` as an empty string**
>
> Note that a name is limited to a number of signs. Min: **1**. Max: **255**.
>
> ```curl {13} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Alex"
>     },
>     {
>       "phone": "45645645666"
>     },
>     {
>       "name": "",
>       "phone": "456456456"
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **4. 4. Set an incorrect phone length**
>
> Note that a phone is limited to a number of signs. Min: **10**. Max: **15**.
>
> ```curl {14} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Alex"
>     },
>     {
>       "phone": "45645645666"
>     },
>     {
>       "name": "",
>       "phone": "456456456"
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **5. 5. As a result, the API returns a `200` status response specifying that the data were set incorreclty.**
>
> ```curl theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Alex"
>     },
>     {
>       "phone": "45645645666"
>     },
>     {
>       "name": "",
>       "phone": "456456456"
>     }
>   ],
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```

> [accordion] Replace contacts
>
> **1. 1. Use a `contacts` parameter to set an array of contact hashes**
>
> ```curl {5} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Howard",
>       "phone": "12312312333"
>     }
>   ],
>   "force":1,
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **2. 2. Set a name of a contact**
>
> Note that a `name` is limited to a number of signs. Min: **1**. Max: **255**.
>
> ```curl {7} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Howard",
>       "phone": "12312312333"
>     }
>   ],
>   "force":1,
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **3. 3. Set a phone of a contact**
>
> Note that a `phone` is limited to a number of signs. Min: **10**. Max: **15**.
>
> ```curl {8} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Howard",
>       "phone": "12312312333"
>     }
>   ],
>   "force":1,
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **4. 4. Specify if you want to replace existing contacts with the one specified**
>
> Set a `force` as `1` to replace the contacts.
>
> ```curl {11} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Howard",
>       "phone": "12312312333"
>     }
>   ],
>   "force":1,
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **5. 5. Set a device identifier**
>
> Set a `udid` parameter to specify a user's device. If specified, contacts will be replaced for a specified device only.
>
> ```curl {12} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Howard",
>       "phone": "12312312333"
>     }
>   ],
>   "force":1,
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **6. 6. As a result, the API returns a responce specifying that `1` contact was created and `3` deleted.**
>
> ```curl theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Howard",
>       "phone": "12312312333"
>     }
>   ],
>   "force":1,
>   "udid": "2222E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```

> [accordion] Upload address book
>
> **1. 1. Use a `contacts` parameter to set an array of contact hashes**
>
> ```curl {5} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Mike Howard",
>       "phone": "463571393241"
>     },
>     {
>       "name": "Morgan Fuller",
>       "phone": "65021272571"
>     }
>   ],
>   "udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **2. 2. Set a name of the contact**
>
> Use a `name` parameter to set the name of the contact.
>
> ```curl {7, 11} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Mike Howard",
>       "phone": "463571393241"
>     },
>     {
>       "name": "Morgan Fuller",
>       "phone": "65021272571"
>     }
>   ],
>   "udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **3. 3. Set a phone of the contact**
>
> Use a `phone` parameter to set a phone of the contact.
>
> ```curl {8, 12} theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Mike Howard",
>       "phone": "463571393241"
>     },
>     {
>       "name": "Morgan Fuller",
>       "phone": "65021272571"
>     }
>   ],
>   "udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```
>
> **4. 4. As a result, the API returns a `200` status response specifying that the contacts were uploaded.**
>
> ```curl theme={null}
> curl -X POST \
> -H "Content-Type: application/json" \
> -H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
> -d '{
>   "contacts": [
>     {
>       "name": "Mike Howard",
>       "phone": "463571393241"
>     },
>     {
>       "name": "Morgan Fuller",
>       "phone": "65021272571"
>     }
>   ],
>   "udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
> }' \
> https://api.quickblox.com/address_book.json
> ```

This API allows you to do following things:

* Upload new address book.
* Replace old address book with a new one.
* Add/delete individual contacts.
* Update existing contacts.

#### Body Parameters

**contacts** `array` *required*

Contains an array of contact objects. Each contact can contain 3 keys - `phone`, `name`, and `destroy`.

**object**

**phone** `string`

Contact phone. Min: 10. Max: 15.

**name** `string`

Contact name. Required only for create/update. Min: 1. Max: 255.

**destroy** `boolean`

Used in a case of a contact destroy. Set `destroy=1` to apply.

**force** `integer`

Defines force rewrite mode. Set `force=1` to apply, then all previous contacts for the device context
will be replaced by new ones.

**udid** `string`

User's device identifier. If specified, all operations will be in this context. Max. length is 64 symbols.
If the device identifier is not specified, it means that a user has one global address book across all
their devices.

#### Headers

**QB-Token** `string` *required*

A user session token. See [Authentication](https://docs.quickblox.com/reference/authentication.md) page to learn more about the session token.

#### Responses

> [accordion] 200
>
> A successful response
>
> **created** `integer`
>
> **updated** `integer`
>
> **deleted** `integer`

```bash cURL theme={null}
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 6d59d901c1231a4d74572224b88ccbc487012bba" \
-d '{
  "contacts": [
    {
      "name": "Mike Howard",
      "phone": "463571393241"
    },
    {
      "name": "Morgan Fuller",
      "phone": "65021272571"
    }
  ],
  "udid": "A337E8A4-80AD-8ABA-9F5D-579EFF6BACAB"
}' \
https://api.quickblox.com/address_book.json
```

```json 200 theme={null}
{
  "created": 2,
  "updated": 0,
  "deleted": 0
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.