# Delete CSV

DELETE https://services.leadconnectorhq.com/social-media-posting/{locationId}/csv/{id}

Delete a CSV import and all its associated posts

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location Id |
| `id` | string | Yes | CSV Id |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/social-media-posting/{locationId}/csv/{id}": {
      "delete": {
        "summary": "Delete CSV",
        "operationId": "deleteCsv",
        "description": "Delete a CSV import and all its associated posts",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location Id",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "CSV Id",
            "schema": {
              "example": "65f92e55cc884f0d0845e447",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteCsvResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "socialplanner/csv.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": {
      "DeleteCsvResponseDTO": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Success or Failure",
            "example": true
          },
          "statusCode": {
            "type": "number",
            "description": "Status Code",
            "example": 200
          },
          "message": {
            "type": "string",
            "description": "Message",
            "example": "Deleted CSV"
          },
          "results": {
            "description": "Requested Results",
            "example": {
              "csv": {
                "locationId": "ve9EPM428h8vShlRW1KT",
                "fileName": "sample.csv",
                "status": "deleted",
                "count": 5
              }
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "csv": {
                    "description": "CSV Data",
                    "example": {
                      "locationId": "ve9EPM428h8vShlRW1KT",
                      "fileName": "sample.csv",
                      "status": "completed",
                      "count": 5
                    },
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "locationId": {
                            "type": "string",
                            "description": "Location Id",
                            "example": "ve9EPM428h8vShlRW1KT"
                          },
                          "fileName": {
                            "type": "string",
                            "description": "Name of the CSV file",
                            "example": "sample.csv"
                          },
                          "accountIds": {
                            "description": "Account Ids",
                            "example": [
                              "aF3KhyL8JIuBwzK3m7Ly_iVrVJ2uoXNF0wzcBzgl5_12554616564525983496"
                            ],
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "file": {
                            "type": "string",
                            "description": "File path of the CSV",
                            "example": "omaDY3RbWtTP511e/social-import/d23d68c2-82c0-1db6e2.csv"
                          },
                          "status": {
                            "type": "string",
                            "description": "CSV import status",
                            "example": "completed",
                            "enum": [
                              "pending",
                              "in_progress",
                              "completed",
                              "failed",
                              "in_review",
                              "importing",
                              "deleted"
                            ]
                          },
                          "count": {
                            "type": "number",
                            "description": "Number of posts in the CSV",
                            "example": 5
                          },
                          "createdBy": {
                            "type": "string",
                            "description": "User Id who created the CSV import",
                            "example": "AccountId_SDsdfdf45Dgs4w3ssss"
                          },
                          "traceId": {
                            "type": "string",
                            "description": "Trace ID for debugging",
                            "example": "FSeSDsdfdf45Dgs4w3ssss"
                          },
                          "originId": {
                            "type": "string",
                            "description": "Origin Id for tracking source",
                            "example": "FSeSDsdfdf45Dgs4w3ssss"
                          },
                          "approver": {
                            "type": "string",
                            "description": "Approver User Id",
                            "example": "FSeSDsdfdf45Dgs4w3ssss"
                          },
                          "csvFileType": {
                            "type": "string",
                            "description": "CSV file type",
                            "example": "basic",
                            "enum": [
                              "basic",
                              "advance"
                            ]
                          },
                          "mediaOptimization": {
                            "type": "boolean",
                            "description": "Media optimization flag",
                            "example": true
                          },
                          "applyWatermark": {
                            "type": "boolean",
                            "description": "Apply watermark flag",
                            "example": false
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string",
                            "description": "Date Updated",
                            "example": "2023-08-02T00:00:00.000Z"
                          }
                        },
                        "title": "CsvResponse"
                      }
                    ]
                  }
                },
                "title": "CSVResponseSchema"
              }
            ]
          }
        },
        "required": [
          "success",
          "statusCode",
          "message"
        ],
        "title": "DeleteCsvResponseDTO"
      },
      "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 DELETE 'https://services.leadconnectorhq.com/social-media-posting/<locationId>/csv/<id>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

```javascript
const options = {
  method: 'DELETE',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/social-media-posting/<locationId>/csv/<id>', 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}/csv/{id}"

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

response = requests.delete(url, 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>/csv/<id>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .delete("https://services.leadconnectorhq.com/social-media-posting/<locationId>/csv/<id>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/social-media-posting/<locationId>/csv/<id>"
  req, _ := http.NewRequest("DELETE", url, nil)
  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>/csv/<id>")

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

request = Net::HTTP::Delete.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"

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

**PowerShell**

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

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/social-media-posting/<locationId>/csv/<id>' -Method 'DELETE' -Headers $headers
$response | ConvertTo-Json
```
