{
 "openapi": "3.1.0",
 "info": {
  "title": "slomo API",
  "version": "1.0.0",
  "description": "Turn video into smooth AI slow motion. Docs: https://slomo.com/docs/api"
 },
 "servers": [
  {
   "url": "https://slomo.com/api/v1"
  }
 ],
 "security": [
  {
   "apiKey": []
  }
 ],
 "paths": {
  "/clips": {
   "post": {
    "summary": "Create a clip",
    "operationId": "createClip",
    "parameters": [
     {
      "name": "Idempotency-Key",
      "in": "header",
      "schema": {
       "type": "string",
       "maxLength": 255
      },
      "description": "Retrying with the same key returns the same clip."
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "additionalProperties": false,
        "description": "Send exactly one of source_url or upload.",
        "properties": {
         "source_url": {
          "type": "string",
          "format": "uri",
          "description": "Public https URL of the video."
         },
         "upload": {
          "type": "object",
          "required": [
           "content_type",
           "size_bytes"
          ],
          "properties": {
           "filename": {
            "type": "string"
           },
           "content_type": {
            "enum": [
             "video/mp4",
             "video/quicktime",
             "video/webm",
             "video/x-matroska"
            ]
           },
           "size_bytes": {
            "type": "integer"
           }
          }
         },
         "factor": {
          "enum": [
           2,
           4,
           8,
           16
          ],
          "default": 4
         },
         "trim_start": {
          "type": "number",
          "minimum": 0
         },
         "trim_end": {
          "type": "number"
         },
         "webhook_url": {
          "type": "string",
          "format": "uri"
         },
         "slow_start": {
          "type": "number",
          "minimum": 0,
          "description": "Speed ramp: slow only from here (seconds). Send with slow_end."
         },
         "slow_end": {
          "type": "number",
          "description": "Speed ramp: slow only until here (seconds). The rest plays at normal speed."
         },
         "audio": {
          "type": "boolean",
          "default": false,
          "description": "Keep the video's sound, slowed (same pitch) to match the picture."
         }
        }
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Created",
      "content": {
       "application/json": {
        "schema": {
         "allOf": [
          {
           "$ref": "#/components/schemas/Clip"
          },
          {
           "type": "object",
           "properties": {
            "upload": {
             "type": "object",
             "description": "Only when created with `upload`.",
             "properties": {
              "url": {
               "type": "string"
              },
              "method": {
               "const": "PUT"
              },
              "headers": {
               "type": "object"
              },
              "expires_in": {
               "type": "integer"
              }
             }
            }
           }
          }
         ]
        }
       }
      }
     },
     "200": {
      "description": "Existing clip for this Idempotency-Key",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Clip"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   },
   "get": {
    "summary": "List clips",
    "operationId": "listClips",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 20
      }
     },
     {
      "name": "starting_after",
      "in": "query",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "object": {
           "const": "list"
          },
          "data": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Clip"
           }
          },
          "has_more": {
           "type": "boolean"
          }
         }
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/clips/{id}": {
   "parameters": [
    {
     "name": "id",
     "in": "path",
     "required": true,
     "schema": {
      "type": "string",
      "format": "uuid"
     }
    }
   ],
   "get": {
    "summary": "Get a clip",
    "operationId": "getClip",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Clip"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   },
   "delete": {
    "summary": "Delete a finished clip",
    "operationId": "deleteClip",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "object": {
           "const": "clip"
          },
          "deleted": {
           "const": true
          }
         }
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/clips/{id}/start": {
   "parameters": [
    {
     "name": "id",
     "in": "path",
     "required": true,
     "schema": {
      "type": "string",
      "format": "uuid"
     }
    }
   ],
   "post": {
    "summary": "Start processing an uploaded clip",
    "operationId": "startClip",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Clip"
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/account": {
   "get": {
    "summary": "Credit balance and limits",
    "operationId": "getAccount",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "object": {
           "const": "account"
          },
          "plan": {
           "type": "string"
          },
          "credits": {
           "type": "integer"
          },
          "active_clips": {
           "type": "integer"
          },
          "limits": {
           "type": "object",
           "properties": {
            "max_height": {
             "type": "integer"
            },
            "max_duration_sec": {
             "type": "integer"
            },
            "max_factor": {
             "type": "integer"
            },
            "max_upload_bytes": {
             "type": "integer"
            },
            "max_active_clips": {
             "type": "integer"
            },
            "watermark": {
             "type": "boolean"
            },
            "retention_days": {
             "type": "integer"
            }
           }
          }
         }
        }
       }
      }
     },
     "default": {
      "description": "Error",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "webhooks": {
  "clip.finished": {
   "post": {
    "summary": "Sent to webhook_url when a clip succeeds or fails",
    "description": "Signed: x-slomo-signature = 'sha256=' + HMAC-SHA256(webhook secret, `${x-slomo-timestamp}.${body}`).",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "type": {
          "enum": [
           "clip.succeeded",
           "clip.failed"
          ]
         },
         "created": {
          "type": "integer"
         },
         "data": {
          "type": "object",
          "properties": {
           "clip": {
            "$ref": "#/components/schemas/Clip"
           }
          }
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx acknowledges it."
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "apiKey": {
    "type": "http",
    "scheme": "bearer",
    "description": "Authorization: Bearer slomo_live_..."
   }
  },
  "schemas": {
   "Clip": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid"
     },
     "object": {
      "const": "clip"
     },
     "status": {
      "enum": [
       "awaiting_upload",
       "queued",
       "processing",
       "succeeded",
       "failed",
       "deleted"
      ]
     },
     "factor": {
      "enum": [
       2,
       4,
       8,
       16
      ]
     },
     "trim_start": {
      "type": [
       "number",
       "null"
      ]
     },
     "trim_end": {
      "type": [
       "number",
       "null"
      ]
     },
     "error": {
      "type": [
       "string",
       "null"
      ]
     },
     "credits_charged": {
      "type": [
       "integer",
       "null"
      ]
     },
     "input": {
      "type": [
       "object",
       "null"
      ],
      "properties": {
       "width": {
        "type": "integer"
       },
       "height": {
        "type": "integer"
       },
       "fps": {
        "type": "number"
       },
       "duration": {
        "type": "number"
       }
      }
     },
     "output_frames": {
      "type": [
       "integer",
       "null"
      ]
     },
     "watermark": {
      "type": "boolean"
     },
     "download_url": {
      "type": [
       "string",
       "null"
      ],
      "description": "Valid for one hour. Fetch the clip again for a fresh link."
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "completed_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "expires_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "slow_start": {
      "type": [
       "number",
       "null"
      ]
     },
     "slow_end": {
      "type": [
       "number",
       "null"
      ]
     },
     "audio": {
      "type": "boolean"
     }
    }
   },
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "object",
      "properties": {
       "code": {
        "type": "string"
       },
       "message": {
        "type": "string"
       }
      }
     }
    }
   }
  }
 }
}