> ## 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 an image project completes. Reference download arrays, credits, image count, project type, and verified request shape for integrations.

# Image Completed



## OpenAPI

````yaml post /image.completed
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:
  /image.completed:
    post:
      tags:
        - Image Events
      summary: Image Completed
      description: >-
        The request example illustrates what your webhook endpoint should
        expect.
      operationId: image.completed
      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:
                    - image.completed
                payload:
                  type: object
                  properties:
                    id:
                      type: string
                      example: cuid-example
                      description: >-
                        Unique ID of the image. Use it with the [Get image
                        Project
                        API](https://docs.magichour.ai/api-reference/image-projects/get-image-details)
                        to fetch status and downloads.
                    name:
                      type: string
                      nullable: true
                      description: The name of the image.
                      example: Example Name
                    status:
                      type: string
                      enum:
                        - draft
                        - queued
                        - rendering
                        - complete
                        - error
                        - canceled
                      description: The status of the image.
                      example: complete
                    image_count:
                      type: integer
                      description: Number of images generated
                      example: 1
                    type:
                      type: string
                      description: >-
                        The type of the image project. Possible values are
                        FACE_EDITOR, AI_IMAGE_EDITOR, AI_SELFIE, AI_HEADSHOT,
                        AI_IMAGE, AI_MEME, CLOTHES_CHANGER, BACKGROUND_REMOVER,
                        FACE_SWAP, IMAGE_UPSCALER, AI_GIF, QR_CODE,
                        PHOTO_EDITOR, PHOTO_COLORIZER, HEAD_SWAP, BODY_SWAP,
                        STORYBOARD
                      example: AI_IMAGE
                    created_at:
                      type: string
                      format: date-time
                    enabled:
                      type: boolean
                      description: >-
                        Whether this resource is active. If false, it is
                        deleted.
                    credits_charged:
                      type: integer
                      example: 5
                      description: >-
                        The amount of credits deducted from your account to
                        generate the image. We charge credits right when the
                        request is made. 


                        If an error occurred while generating the image(s),
                        credits will be refunded and this field will be updated
                        to include the refund.
                    downloads:
                      type: array
                      items:
                        type: object
                        properties:
                          url:
                            type: string
                            format: uri
                            example: https://videos.magichour.ai/id/output.png
                          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
                    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
                  required:
                    - id
                    - name
                    - status
                    - image_count
                    - type
                    - created_at
                    - enabled
                    - total_frame_cost
                    - credits_charged
                    - downloads
                    - error
                  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

````