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

# Create Subscription

> Create a new webhook subscription.

Creates a webhook subscription for receiving events (e.g., asset processing completion).
The endpoint must use HTTPS and will receive signed webhook payloads.

Authentication: Requires X-API-Key header with valid API key.

Args:
    request_data: Webhook subscription creation request
    identity: Authenticated API key identity
    webhook_adapter: Webhook adapter for creating subscriptions (injected)
    repository: Repository for persisting subscriptions (injected)

Returns:
    WebhookSubscriptionResponse with subscription details and signing secret

Raises:
    401: If API key missing or invalid
    422: If request validation fails (e.g., non-HTTPS URL) or the
         workspace has reached its webhook subscription limit

Example:
    POST /api/v1/integrations/webhooks/subscriptions
    {
        "endpoint_url": "https://example.com/webhooks",
        "event_types": ["asset.processing.completed", "asset.processing.failed"],
        "description": "Production webhook endpoint"
    }

    Response (201):
    {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "workspace_id": "660e8400-e29b-41d4-a716-446655440001",
        "endpoint_url": "https://example.com/webhooks",
        "secret": "whsec_AbCdEf1234567890...",
        "event_types": ["asset.processing.completed", "asset.processing.failed"],
        "description": "Production webhook endpoint",
        "enabled": true,
        "created_at": "2026-04-09T12:00:00Z",
        "updated_at": "2026-04-09T12:00:00Z"
    }



## OpenAPI

````yaml post /api/integrations/webhooks/subscriptions
openapi: 3.1.0
info:
  title: Midmarket Integrations API
  description: An API for Midmarket integrations.
  version: 0.1.0
servers:
  - url: https://mm-midmarket-integrations-api-preview.azurewebsites.net
    description: preview
security: []
paths:
  /api/integrations/webhooks/subscriptions:
    post:
      tags:
        - webhooks
      summary: Create Subscription
      description: >-
        Create a new webhook subscription.


        Creates a webhook subscription for receiving events (e.g., asset
        processing completion).

        The endpoint must use HTTPS and will receive signed webhook payloads.


        Authentication: Requires X-API-Key header with valid API key.


        Args:
            request_data: Webhook subscription creation request
            identity: Authenticated API key identity
            webhook_adapter: Webhook adapter for creating subscriptions (injected)
            repository: Repository for persisting subscriptions (injected)

        Returns:
            WebhookSubscriptionResponse with subscription details and signing secret

        Raises:
            401: If API key missing or invalid
            422: If request validation fails (e.g., non-HTTPS URL) or the
                 workspace has reached its webhook subscription limit

        Example:
            POST /api/v1/integrations/webhooks/subscriptions
            {
                "endpoint_url": "https://example.com/webhooks",
                "event_types": ["asset.processing.completed", "asset.processing.failed"],
                "description": "Production webhook endpoint"
            }

            Response (201):
            {
                "id": "550e8400-e29b-41d4-a716-446655440000",
                "workspace_id": "660e8400-e29b-41d4-a716-446655440001",
                "endpoint_url": "https://example.com/webhooks",
                "secret": "whsec_AbCdEf1234567890...",
                "event_types": ["asset.processing.completed", "asset.processing.failed"],
                "description": "Production webhook endpoint",
                "enabled": true,
                "created_at": "2026-04-09T12:00:00Z",
                "updated_at": "2026-04-09T12:00:00Z"
            }
      operationId: create_subscription_api_integrations_webhooks_subscriptions_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookSubscriptionRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateWebhookSubscriptionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - apiKey: []
components:
  schemas:
    CreateWebhookSubscriptionRequest:
      properties:
        endpointUrl:
          type: string
          maxLength: 2083
          minLength: 1
          format: uri
          title: Endpointurl
          description: HTTPS endpoint to receive webhook events
        eventTypes:
          items:
            $ref: '#/components/schemas/WebhookEventType'
          type: array
          minItems: 1
          title: Eventtypes
          description: >-
            Event types to subscribe to. Allowed values:
            asset.processing.completed, asset.processing.failed
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Optional human-readable description
      type: object
      required:
        - endpointUrl
        - eventTypes
      title: CreateWebhookSubscriptionRequest
      description: Request model for creating a webhook subscription.
      example:
        description: Notify when an asset finishes processing
        endpointUrl: https://your-server.example.com/webhooks
        eventTypes:
          - asset.processing.completed
    CreateWebhookSubscriptionResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
          description: Subscription ID
        workspaceId:
          type: string
          format: uuid
          title: Workspaceid
          description: Workspace ID
        endpointUrl:
          type: string
          title: Endpointurl
          description: Webhook endpoint URL
        eventTypes:
          items:
            type: string
          type: array
          title: Eventtypes
          description: Subscribed event types
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Subscription description
        enabled:
          type: boolean
          title: Enabled
          description: Whether subscription is active
        createdAt:
          type: string
          format: date-time
          title: Createdat
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          title: Updatedat
          description: Last update timestamp
        secret:
          type: string
          title: Secret
          description: Signing secret for verifying webhook signatures (shown only once)
      type: object
      required:
        - id
        - workspaceId
        - endpointUrl
        - eventTypes
        - enabled
        - createdAt
        - updatedAt
        - secret
      title: CreateWebhookSubscriptionResponse
      description: >-
        Response model for creating a webhook subscription (includes one-time
        secret).


        The signing secret is only shown once at creation time. The customer
        must

        store this secret to verify webhook signatures from Hookdeck.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    WebhookEventType:
      type: string
      enum:
        - asset.processing.completed
        - asset.processing.failed
      title: WebhookEventType
      description: All event types that can be delivered via webhooks.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: 'Workspace-scoped API key. Format: sk_live_{64 hex chars}'
      x-default: sk_live_your_api_key_here

````