# Bulk Delete Social Planner Posts

POST https://services.leadconnectorhq.com/social-media-posting/{locationId}/posts/bulk-delete

Deletes multiple posts based on the provided list of post IDs. 
                  This operation is useful for clearing up large numbers of posts efficiently. 
                  
Note: 
                  
1.The maximum number of posts that can be deleted in a single request is '50'.
                  
2.However, It will only get deleted in the platform database but still
                   it is recommended to be cautious of this operation.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `socialplanner/post.write`

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location ID (also known as Sub-Account ID) for the business location. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/social-media-posting/{locationId}/posts/bulk-delete": {
      "post": {
        "summary": "Bulk Delete Social Planner Posts",
        "operationId": "bulkDeleteSocialPlannerPosts",
        "description": "Deletes multiple posts based on the provided list of post IDs. \n                  This operation is useful for clearing up large numbers of posts efficiently. \n                  \nNote: \n                  \n1.The maximum number of posts that can be deleted in a single request is '50'.\n                  \n2.However, It will only get deleted in the platform database but still\n                   it is recommended to be cautious of this operation.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location ID (also known as Sub-Account ID) for the business location.",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeletePostsDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Posts deleted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeleteResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Cannot delete more than 50 posts at a time.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "404": {
            "description": "No posts found with the given IDs."
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          },
          "500": {
            "description": "An error occurred while trying to delete the posts. Please try again later."
          }
        },
        "security": [
          {
            "Location-Access": [
              "socialplanner/post.write"
            ]
          }
        ]
      }
    }
  },
  "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": {
      "DeletePostsDto": {
        "type": "object",
        "properties": {
          "postIds": {
            "description": "Post identifiers to delete. Each is either a 24-char post id or a 40-char native post id.",
            "example": [
              "662791ee3f216822d7da0c8c"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "title": "DeletePostsDto"
      },
      "BulkDeleteResponseDto": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Success or Failure",
            "example": true
          },
          "statusCode": {
            "type": "number",
            "description": "Status Code",
            "example": 201
          },
          "message": {
            "type": "string",
            "description": "Message",
            "example": "Posts Deleted Successfully"
          },
          "results": {
            "description": "Message and deleted count",
            "example": {
              "message": "Posts deleted successfully",
              "deletedCount": 10
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string",
                    "description": "Result message",
                    "example": "Posts deleted successfully"
                  },
                  "deletedCount": {
                    "type": "number",
                    "description": "Number of posts successfully deleted",
                    "example": 10
                  }
                },
                "required": [
                  "message"
                ],
                "title": "BulkDeletePostSuccessfulResponseSchema"
              }
            ]
          }
        },
        "required": [
          "success",
          "statusCode",
          "message",
          "results"
        ],
        "title": "BulkDeleteResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "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/social-media-posting/<locationId>/posts/bulk-delete' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "postIds": [
    "662791ee3f216822d7da0c8c"
  ]
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "postIds": [
        "662791ee3f216822d7da0c8c"
      ]
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/social-media-posting/<locationId>/posts/bulk-delete', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/social-media-posting/{locationId}/posts/bulk-delete"

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

payload = {
    "postIds": [
        "662791ee3f216822d7da0c8c"
    ]
}

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/social-media-posting/<locationId>/posts/bulk-delete',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "postIds": [
    "662791ee3f216822d7da0c8c"
  ]
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/social-media-posting/<locationId>/posts/bulk-delete")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"postIds\":[\"662791ee3f216822d7da0c8c\"]}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/social-media-posting/<locationId>/posts/bulk-delete"
  payload := strings.NewReader(`{
  "postIds": [
    "662791ee3f216822d7da0c8c"
  ]
}`)
  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/social-media-posting/<locationId>/posts/bulk-delete")

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 = '{
  "postIds": [
    "662791ee3f216822d7da0c8c"
  ]
}'

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

**PowerShell**

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

$body = '{
  "postIds": [
    "662791ee3f216822d7da0c8c"
  ]
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/social-media-posting/<locationId>/posts/bulk-delete' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
