# Update Contacts Tags

POST https://services.leadconnectorhq.com/contacts/bulk/tags/update/{type}

Allows you to update tags to multiple contacts at once, you can add or remove tags from the contacts

## Authentication

None: this endpoint declares no security requirement, so no `Authorization` header is needed.

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/contacts/bulk/tags/update/{type}": {
      "post": {
        "summary": "Update Contacts Tags",
        "operationId": "updateContactsTags",
        "description": "Allows you to update tags to multiple contacts at once, you can add or remove tags from the contacts",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTagsDTO"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateTagsResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "UpdateTagsDTO": {
        "type": "object",
        "properties": {
          "contacts": {
            "description": "list of contact ids to be processed",
            "example": [
              "qFSqySFkVvNzOSqgGqFi",
              "abcdef",
              "qFSqySFkVvNzOSqgGqFi",
              "3ualbhnV7j3n3a9r2moD"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tags": {
            "description": "list of tags to be added or removed",
            "example": [
              "tag-1",
              "tag-2"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "locationId": {
            "type": "string",
            "description": "location id from where the bulk request is executed",
            "example": "asdrwHvLUxlfw5SqKVCN"
          },
          "removeAllTags": {
            "type": "boolean",
            "description": "Option to implement remove all tags. if true, all tags will be removed from the contacts. Can only be used with remove type.",
            "example": "false"
          }
        },
        "required": [
          "contacts",
          "tags",
          "locationId"
        ],
        "title": "UpdateTagsDTO"
      },
      "UpdateTagsResponseDTO": {
        "type": "object",
        "properties": {
          "succeeded": {
            "type": "boolean",
            "description": "Indicates if the operation was successful",
            "example": true
          },
          "succeded": {
            "type": "boolean",
            "description": "Legacy misspelling of `succeeded`. Deprecated; use `succeeded`.",
            "example": true,
            "deprecated": true
          },
          "errorCount": {
            "type": "number",
            "description": "Number of errors encountered during the operation",
            "example": 0
          },
          "responses": {
            "description": "Responses for each contact processed",
            "example": [
              {
                "contactId": "qFSqySFkVvNzOSqgGqFi",
                "message": "Tags updated",
                "type": "success",
                "oldTags": [
                  "tag-1",
                  "tag-2"
                ],
                "tagsAdded": [],
                "tagsRemoved": []
              },
              {
                "contactId": "abcdef",
                "message": "contact id is not a valid firebase id",
                "type": "error"
              },
              {
                "contactId": "qFSqySFkVvNzOSqgGqFi",
                "message": "contact is deleted",
                "type": "error"
              },
              {
                "contactId": "3ualbhnV7j3n3a9r2moD",
                "message": "contact does not belong to location",
                "type": "error"
              }
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "succeeded",
          "succeded",
          "errorCount",
          "responses"
        ],
        "title": "UpdateTagsResponseDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/contacts/bulk/tags/update/<type>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "contacts": [
    "qFSqySFkVvNzOSqgGqFi",
    "abcdef",
    "qFSqySFkVvNzOSqgGqFi",
    "3ualbhnV7j3n3a9r2moD"
  ],
  "tags": [
    "tag-1",
    "tag-2"
  ],
  "locationId": "asdrwHvLUxlfw5SqKVCN",
  "removeAllTags": "false"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "contacts": [
        "qFSqySFkVvNzOSqgGqFi",
        "abcdef",
        "qFSqySFkVvNzOSqgGqFi",
        "3ualbhnV7j3n3a9r2moD"
      ],
      "tags": [
        "tag-1",
        "tag-2"
      ],
      "locationId": "asdrwHvLUxlfw5SqKVCN",
      "removeAllTags": "false"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/contacts/bulk/tags/update/<type>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/contacts/bulk/tags/update/{type}"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "contacts": [
        "qFSqySFkVvNzOSqgGqFi",
        "abcdef",
        "qFSqySFkVvNzOSqgGqFi",
        "3ualbhnV7j3n3a9r2moD"
    ],
    "tags": [
        "tag-1",
        "tag-2"
    ],
    "locationId": "asdrwHvLUxlfw5SqKVCN",
    "removeAllTags": "false"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/contacts/bulk/tags/update/<type>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "contacts": [
    "qFSqySFkVvNzOSqgGqFi",
    "abcdef",
    "qFSqySFkVvNzOSqgGqFi",
    "3ualbhnV7j3n3a9r2moD"
  ],
  "tags": [
    "tag-1",
    "tag-2"
  ],
  "locationId": "asdrwHvLUxlfw5SqKVCN",
  "removeAllTags": "false"
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/contacts/bulk/tags/update/<type>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"contacts\":[\"qFSqySFkVvNzOSqgGqFi\",\"abcdef\",\"qFSqySFkVvNzOSqgGqFi\",\"3ualbhnV7j3n3a9r2moD\"],\"tags\":[\"tag-1\",\"tag-2\"],\"locationId\":\"asdrwHvLUxlfw5SqKVCN\",\"removeAllTags\":\"false\"}")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
  "strings"
)

func main() {
  url := "https://services.leadconnectorhq.com/contacts/bulk/tags/update/<type>"
  payload := strings.NewReader(`{
  "contacts": [
    "qFSqySFkVvNzOSqgGqFi",
    "abcdef",
    "qFSqySFkVvNzOSqgGqFi",
    "3ualbhnV7j3n3a9r2moD"
  ],
  "tags": [
    "tag-1",
    "tag-2"
  ],
  "locationId": "asdrwHvLUxlfw5SqKVCN",
  "removeAllTags": "false"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/contacts/bulk/tags/update/<type>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "contacts": [
    "qFSqySFkVvNzOSqgGqFi",
    "abcdef",
    "qFSqySFkVvNzOSqgGqFi",
    "3ualbhnV7j3n3a9r2moD"
  ],
  "tags": [
    "tag-1",
    "tag-2"
  ],
  "locationId": "asdrwHvLUxlfw5SqKVCN",
  "removeAllTags": "false"
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "contacts": [
    "qFSqySFkVvNzOSqgGqFi",
    "abcdef",
    "qFSqySFkVvNzOSqgGqFi",
    "3ualbhnV7j3n3a9r2moD"
  ],
  "tags": [
    "tag-1",
    "tag-2"
  ],
  "locationId": "asdrwHvLUxlfw5SqKVCN",
  "removeAllTags": "false"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/contacts/bulk/tags/update/<type>' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
