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

# Trim Video

> Trim a video to a specific start and end time and return the resulting asset.

## Description

This endpoint allows users to trim a video from a specified URL based on start and end timestamps. The trimmed video is then uploaded to R2 storage, and the URL of the trimmed video is returned.

## Endpoint

```
POST https://app.dumplingai.com/api/v1/trim-video
```

## Headers

* **Content-Type:** `application/json`
* **Authorization:** Bearer `<API_KEY>` (required)

## Request Body

```json theme={null}
{
  "videoUrl": "string", // Required. The URL of the video to trim. Only MP4 videos are supported.
  "startTimestamp": "string", // Required. The start time of the trim in HH:MM:SS format.
  "endTimestamp": "string" // Required. The end time of the trim in HH:MM:SS format.
}
```

## Responses

### Success (200)

Returns the URL of the trimmed video and the number of credits used.

```json theme={null}
{
  "trimmedVideoUrl": "string", // URL of the trimmed video
  "creditsUsed": "number" // Number of credits used for this operation
}
```

* **X-RateLimit-Limit:** The rate limit for the user.
* **X-RateLimit-Remaining:** The remaining number of requests for the user.

### Bad Request (400)

Returned if the request is invalid or missing required parameters.

```json theme={null}
{
  "error": "Error message describing the issue"
}
```

### Internal Server Error (500)

Returned if there's an error during the video trimming process.

```json theme={null}
{
  "error": "Failed to trim video"
}
```

## Example Request

```bash theme={null}
curl -X POST https://app.dumplingai.com/api/v1/trim-video \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
  "videoUrl": "https://example.com/video.mp4",
  "startTimestamp": "00:00:10",
  "endTimestamp": "00:00:30"
}'
```

## Example Response

```json theme={null}
{
  "trimmedVideoUrl": "https://storage.example.com/trimmed-videos/abcdef123456.mp4",
  "creditsUsed": 5
}
```

## Notes

* The timestamp format should be HH:MM:SS (e.g., 00:01:15 for 1 minute and 15 seconds).
* Credits used are calculated based on the duration of the output video (200 credits per minute, rounded up).
* Output videos are limited to 200MB in size. You can reduce the size of the output video by trimming a smaller portion of the input video.
* The trimmed video is temporarily stored (\~24 hours).

## Rate Limiting

Rate limit headers (`X-RateLimit-Limit` and `X-RateLimit-Remaining`) are included in the response to indicate the user's current rate limit status.


## OpenAPI

````yaml POST /api/v1/trim-video
openapi: 3.0.3
info:
  title: DumplingAI API
  version: 1.0.0
  description: >
    REST API for DumplingAI's content intelligence and automation platform.

    All endpoints are grouped under `/api/v1`; most are secured via Bearer API
    keys unless an operation explicitly sets `security: []`.
servers:
  - url: https://app.dumplingai.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: YouTube
    description: Access metadata, search results, and transcripts from YouTube.
  - name: TikTok
    description: Retrieve TikTok profile, video, follower, and transcript data.
  - name: LinkedIn
    description: Programmatically fetch LinkedIn company and profile data.
  - name: Search
    description: Search-orientated endpoints spanning web, news, maps, and autocomplete.
  - name: Google
    description: Integrations with Google business listings and location data.
  - name: Scraping
    description: Webpage capture, crawling, and structured content extraction utilities.
  - name: Documents
    description: Document processing, conversion, and metadata utilities.
  - name: AI
    description: DumplingAI agent and knowledge base endpoints.
  - name: Developer Tools
    description: Utilities for executing sandboxed code via API.
paths:
  /api/v1/trim-video:
    post:
      tags:
        - Documents
      summary: Trim video
      description: >-
        Trim a video to a specific start and end time and return the resulting
        asset.
      operationId: trimVideo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TrimVideoRequest'
            examples:
              default:
                value:
                  videoUrl: https://example.com/video.mp4
                  startTimestamp: '00:00:05'
                  endTimestamp: '00:00:20'
      responses:
        '200':
          description: Trimmed video returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrimVideoResponse'
        '400':
          description: Invalid request payload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
        '500':
          description: Unexpected server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    TrimVideoRequest:
      type: object
      required:
        - videoUrl
        - startTimestamp
        - endTimestamp
      properties:
        videoUrl:
          type: string
          format: uri
          description: Publicly accessible MP4 URL to trim.
        startTimestamp:
          type: string
          description: Start timecode for the trim in HH:MM:SS or HH:MM:SS.mmm format.
        endTimestamp:
          type: string
          description: End timecode for the trim in HH:MM:SS or HH:MM:SS.mmm format.
        requestSource:
          $ref: '#/components/schemas/RequestSource'
      additionalProperties: false
    TrimVideoResponse:
      type: object
      required:
        - trimmedVideoUrl
        - creditsUsed
      properties:
        trimmedVideoUrl:
          type: string
          format: uri
          description: Temporary download URL for the trimmed video asset.
        creditsUsed:
          type: integer
          description: Credits consumed while processing the request.
      additionalProperties: false
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable description of what went wrong.
      required:
        - error
    RequestSource:
      type: string
      description: Optional identifier describing where the API request originated.
      enum:
        - API
        - WEB
        - MAKE_DOT_COM
        - ZAPIER
        - N8N
        - PLAYGROUND
        - DEFAULT_AUTOMATION
        - AGENT_PREVIEW
        - AGENT_LIVE
        - AUTOPILOT
        - STUDIO
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````