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

# Delete File

> Remove one file from a post. Removing the last file deletes the post.

Remove one file from a post.

## Behavior

* `name` is the stored file name from `files[].name`: 32 lowercase hex characters, a dot, and the extension (for example `a1b2c3d4e5f6789012345678abcdef01.png`). The extension is required.
* Removing a file from an album keeps the rest of the post. Removing the last file deletes the post.
* You must own the post. A team post needs that team's access key.
* Requires [gallery access](/authentication#api-key-permissions) on the key.
* Files in a moderated post cannot be removed and return `403` with type `moderated`.
* To delete the whole post in one call, use [Delete Post](/api-reference/endpoint/posts/delete).
* Shares a rate limit bucket with Delete Post: 20 requests per 30 seconds.

## Examples

```bash theme={null}
curl -X DELETE "https://api.snipp.gg/posts/AlBm5678/files/b2c3d4e5f6789012345678abcdef0102.png" \
  -H "api-key: YOUR_API_KEY"
```

## Responses

```json theme={null}
{
  "name": "b2c3d4e5f6789012345678abcdef0102.png",
  "deleted": true
}
```

## Errors

| Status | Type | When |
| - | - | - |
| `400` | `invalid_request` | Invalid `code` or `name` |
| `401` | `unauthorized` | Missing or invalid key |
| `403` | `forbidden` | Not your post, or the key has no gallery access |
| `403` | `moderated` | The post is moderated |
| `404` | `not_found` | No such post, or the file is not in it |
| `429` | `rate_limited` | Too many deletes |


## OpenAPI

````yaml api-reference/openapi.json DELETE /posts/{code}/files/{name}
openapi: 3.0.0
info:
  title: Snipp.gg API
  description: Image and video hosting API. Upload, manage, and share media files.
  version: 3.0.0
servers:
  - url: https://api.snipp.gg
    description: Default. Load-balanced across regions. No upload cap.
  - url: https://eu-west-1.api.snipp.gg
    description: EU West regional endpoint. Pins uploads and storage to EU West.
  - url: https://us-west-1.api.snipp.gg
    description: US West regional endpoint. Pins uploads and storage to US West.
  - url: https://flux.snipp.gg
    description: Alternative host. Capped at 100 MB per upload.
security:
  - apiKeyAuth: []
paths:
  /posts/{code}/files/{name}:
    delete:
      summary: Delete File
      description: Remove one file from a post. Removing the last file deletes the post.
      operationId: deleteFile
      parameters:
        - $ref: '#/components/parameters/PostCode'
        - $ref: '#/components/parameters/FileName'
      responses:
        '200':
          description: Success
          headers:
            request-id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                type: object
                properties:
                  name:
                    type: string
                  deleted:
                    type: boolean
                    enum:
                      - true
                required:
                  - name
                  - deleted
              example:
                name: b2c3d4e5f6789012345678abcdef0102.png
                deleted: true
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '403':
          $ref: '#/components/responses/E403'
        '404':
          $ref: '#/components/responses/E404'
        '405':
          $ref: '#/components/responses/E405'
        '429':
          $ref: '#/components/responses/E429'
        '500':
          $ref: '#/components/responses/E500'
components:
  parameters:
    PostCode:
      name: code
      in: path
      required: true
      description: Post share code.
      schema:
        type: string
      example: AbCd1234
    FileName:
      name: name
      in: path
      required: true
      description: Stored file name from `files[].name`.
      schema:
        type: string
        pattern: ^[a-f0-9]{32}\.[a-z0-9]{2,5}$
      example: a1b2c3d4e5f6789012345678abcdef01.png
  headers:
    RequestId:
      description: Unique ID for the request. Include it when contacting support.
      schema:
        type: string
        format: uuid
  responses:
    E400:
      description: Invalid request
      headers:
        request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    E401:
      description: Missing or invalid key
      headers:
        request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    E403:
      description: Not allowed
      headers:
        request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    E404:
      description: Not found
      headers:
        request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    E405:
      description: Method not allowed
      headers:
        request-id:
          $ref: '#/components/headers/RequestId'
        Allow:
          description: Methods this path accepts.
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    E429:
      description: Rate limited
      headers:
        request-id:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    E500:
      description: Internal error
      headers:
        request-id:
          $ref: '#/components/headers/RequestId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - error
      description: Every non-2xx response has this body.
    ErrorDetail:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ErrorType'
        message:
          type: string
          description: Human-readable sentence. Do not match on it; use `type`.
        username:
          type: string
          description: >-
            `suspended` on `GET /users/{id}` only: the suspended user's
            username.
        quota:
          type: integer
          description: '`quota_exceeded` only: weekly quota in bytes.'
        used:
          type: integer
          description: '`quota_exceeded` only: bytes used in the current window.'
        resets_at:
          type: string
          format: date-time
          description: '`quota_exceeded` only: when the weekly window resets.'
          nullable: true
        failed:
          type: array
          items:
            $ref: '#/components/schemas/FailedFile'
          description: '`upload_failed` only: one entry per file.'
      required:
        - type
        - message
    ErrorType:
      type: string
      enum:
        - invalid_request
        - unauthorized
        - forbidden
        - suspended
        - blocked
        - moderated
        - plan_required
        - not_found
        - method_not_allowed
        - file_too_large
        - unsupported_type
        - quota_exceeded
        - rate_limited
        - upload_failed
        - internal
        - unavailable
      description: Machine-readable error category. See [Errors](/concepts/errors).
    FailedFile:
      type: object
      properties:
        index:
          type: integer
          description: Zero-based position of the file in the request.
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - index
        - error
      description: >-
        A file that was not stored. `error` has the same shape as a top-level
        error.
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: api-key
      description: Your API key from an app on snipp.gg/settings/apps

````

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