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

> Magic Hour notifies your server when a video project fails. Webhook reference for error code, message, project id, and HMAC-signed headers your endpoint should validate.

# Video Errored



## OpenAPI

````yaml post /video.errored
openapi: 3.1.0
info:
  title: Magic Hour Webhook
  version: beta
  description: >
    ## Introduction 


    Configuring a webhook allow Magic Hour to notify you whenever an event
    occurs in your account. To get started, create a webhook
    [here](https://magichour.ai/developer).


    API documentation can be found
    [here](https://docs.magichour.ai/webhook-reference).


    If you have any questions, please reach out to us via
    [discord](https://discord.gg/JX5rgsZaJp).


    ## Securing your endpoint


    Events includes two headers to help verify the authenticity of the payload. 

    - `magic-hour-event-signature` - A signatured created with the webhook
    secret key and a signed_payload, using HMAC with SHA-256

    - `magic-hour-event-timestamp` - Time in seconds since the epoch. Use this
    value to check whether the request is within a reasonable window of the
    current time. Usually less than 5 minutes.


    Using the header to verify the request ensures that the request is
    authentic. However, the header verification is optional. 


    To compute the signature to verify:

    1. create a `signed_payload` by concatenating:
          - the timestamp as a string
          - the character `.`
          - the payload JSON (stringified)

    For example, 

    ```txt

    1729314984.{"type":"video.started","object":{"id":"cm2fphlo3000dmfhu8m0dh63z","name":"Video","status":"rendering","type":"TEXT_TO_VIDEO","created_at":"2024-10-19T05:16:19.027Z","width":720,"height":1280,"total_frame_cost":300,"start_seconds":0,"end_seconds":5,"fps":30,"download":null}}

    ```


    2. Compute an HMAC with the SHA256 Hash function. Using the webhook secret
    as the key, and use the `signed_payload` as the message.

    3. Compare the computed hash value against the header and verify that the
    timestamp is within a reasonable window.


    ## Retry behavior


    If event delivery failed, meaning the response from your endpoint does not
    have a status code of `2XX`, we will retry delivery up to 24 hours with
    exponential backoff. After 24 hours, the event will be marked as failed and
    will not be retried.


    In the case where the webhook is disabled, pending events for the webhook
    will be skipped. Please note that these events will also be marked as failed
    after 24 hours.
  termsOfService: https://magichour.ai/terms-of-service
servers:
  - url: https://your-webhook.com
security: []
tags:
  - name: Image Events
    description: Events related to image
  - name: Video Events
    description: Events related to video
  - name: Audio Events
    description: Events related to audio
paths:
  /video.errored:
    post:
      tags:
        - Video Events
      summary: Video Errored
      description: >-
        The request example illustrates what your webhook endpoint should
        expect.
      operationId: video.errored
      parameters:
        - name: magic-hour-event-signature
          in: header
          required: true
          schema:
            type: string
            description: >-
              A signatured created with the webhook secret key and a
              signed_payload, using HMAC with SHA-256
            example: 3e771b50c...
        - name: magic-hour-event-timestamp
          in: header
          required: true
          schema:
            type: string
            description: >-
              Time in seconds since the epoch. Use this value to check whether
              the request is within a reasonable window of the current time.
              Usually less than 5 minutes.
            example: '1730742038'
      requestBody:
        description: Body
        content:
          application/json:
            schema:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - video.errored
                payload:
                  type: object
                  properties:
                    id:
                      type: string
                      example: cuid-example
                      description: >-
                        Unique ID of the video. Use it with the [Get video
                        Project
                        API](https://docs.magichour.ai/api-reference/video-projects/get-video-details)
                        to fetch status and downloads.
                    name:
                      type: string
                      nullable: true
                      description: The name of the video.
                      example: Example Name
                    status:
                      type: string
                      enum:
                        - draft
                        - queued
                        - rendering
                        - complete
                        - error
                        - canceled
                      description: The status of the video.
                      example: complete
                    type:
                      type: string
                      description: >-
                        The type of the video project. Possible values are
                        ANIMATION, AUTO_SUBTITLE, VIDEO_TO_VIDEO, FACE_SWAP,
                        TEXT_TO_VIDEO, IMAGE_TO_VIDEO, LIP_SYNC, TALKING_PHOTO,
                        VIDEO_UPSCALER, EXTEND, AUDIO_TO_VIDEO, VIDEO_EXPANDER,
                        UGC_AD
                      example: FACE_SWAP
                    created_at:
                      type: string
                      format: date-time
                    width:
                      type: integer
                      description: >-
                        The width of the final output video. A value of -1
                        indicates the width can be ignored.
                      example: 512
                    height:
                      type: integer
                      description: >-
                        The height of the final output video. A value of -1
                        indicates the height can be ignored.
                      example: 960
                    enabled:
                      type: boolean
                      description: >-
                        Whether this resource is active. If false, it is
                        deleted.
                    start_seconds:
                      type: number
                      minimum: 0
                      description: Start time of your clip (seconds). Must be ≥ 0.
                      format: float
                      example: 0
                    end_seconds:
                      type: number
                      minimum: 0.1
                      description: >-
                        End time of your clip (seconds). Must be greater than
                        start_seconds.
                      format: float
                      example: 15
                    credits_charged:
                      type: integer
                      description: >-
                        The amount of credits deducted from your account to
                        generate the video. If the status is not 'complete',
                        this value is an estimate and may be adjusted upon
                        completion based on the actual FPS of the output video. 


                        If video generation fails, credits will be refunded, and
                        this field will be updated to include the refund.
                      example: 450
                    fps:
                      type: number
                      description: >-
                        Frame rate of the video. If the status is not
                        'complete', the frame rate is an estimate and will be
                        adjusted when the video completes.
                      example: 30
                    error:
                      type: object
                      properties:
                        message:
                          type: string
                          description: Details on the reason why a failure happened.
                          example: Please use an image with a detectable face
                        code:
                          type: string
                          example: no_source_face
                          description: An error code to indicate why a failure happened.
                      required:
                        - message
                        - code
                      nullable: true
                      description: >-
                        In the case of an error, this object will contain the
                        error encountered during video render
                      example: null
                    downloads:
                      type: array
                      items:
                        type: object
                        properties:
                          url:
                            type: string
                            format: uri
                            example: https://videos.magichour.ai/id/output.mp4
                          expires_at:
                            type: string
                            format: date-time
                            example: '2024-10-19T05:16:19.027Z'
                        required:
                          - url
                          - expires_at
                        description: >-
                          The download url and expiration date of the image
                          project
                  required:
                    - id
                    - name
                    - status
                    - type
                    - created_at
                    - width
                    - height
                    - enabled
                    - start_seconds
                    - end_seconds
                    - total_frame_cost
                    - credits_charged
                    - fps
                    - error
                    - downloads
                    - download
                  description: Success
              required:
                - type
                - payload
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Success message from your endpoint
                required:
                  - message
                description: Success
        '400':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Error message from your endpoint
                required:
                  - message
                description: Error
        '500':
          description: Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Error message from your endpoint
                required:
                  - message
                description: Error

````