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

# Create an Endpoint

> Create a new endpoint.



## OpenAPI

````yaml POST /webhook_endpoints
openapi: 3.1.0
info:
  title: Moonbase REST API
  version: v0
servers:
  - url: https://api.moonbase.ai/v0
security:
  - bearer: []
tags:
  - name: Inboxes
    description: Manage your inboxes, conversations, and messages
  - name: Collections
    description: Manage your collections and items
  - name: Marketing
    description: Manage your marketing campaigns and forms
  - name: Activities
    description: View activities and capture calls
  - name: Library
    description: Manage your meetings, files, and notes
paths:
  /webhook_endpoints:
    post:
      tags:
        - Webhooks
      summary: Create an endpoint
      description: Create a new endpoint.
      parameters: []
      requestBody:
        description: The `WebhookEvent` object to be created.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookEndpointCreateParams'
            examples:
              Create webhook endpoint with subscriptions:
                summary: Create webhook endpoint with subscriptions
                value:
                  url: https://example.com/webhook
                  status: enabled
                  subscriptions:
                    - event_type: activity/item_created
                    - event_type: activity/item_mentioned
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpoint'
              examples:
                Create webhook endpoint with subscriptions:
                  summary: Create webhook endpoint with subscriptions
                  value:
                    id: 1CLJt2v6KXDyzDuM57pQqo
                    type: webhook_endpoint
                    url: https://example.com/webhook
                    status: enabled
                    secret: whsec_02Ri1JbtBUm4MewEXp7QhzHasATk3LdvDWo6PgyGZr9Sj2
                    subscriptions:
                      - type: webhook_subscription
                        event_type: activity/item_created
                      - type: webhook_subscription
                        event_type: activity/item_mentioned
                    created_at: '2025-02-17T16:00:00.000Z'
                    updated_at: '2025-02-17T16:00:00.000Z'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '400'
                        title: Bad Request
                        detail: >-
                          The request could not be understood due to malformed
                          syntax or invalid parameters.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '401'
                        title: Unauthorized
                        detail: >-
                          Invalid or missing API key or JWT. You should provide
                          your Moonbase API Key or JWT in the authorization
                          header, in the format: "Authorization: Bearer
                          MOONBASE_API_KEY"
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '403'
                        title: Forbidden
        '422':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Invalid URL:
                  summary: Invalid URL
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '422'
                        title: Unprocessable Entity
                        detail: Url must use HTTPS
                        source:
                          pointer: /url
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '429'
                        title: Too Many Requests
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '500'
                        title: Internal Server Error
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '503'
                        title: Service Unavailable
                        detail: >-
                          The service is temporarily unavailable, please try
                          again later.
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Moonbase from '@moonbaseai/sdk';

            const client = new Moonbase({
              apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
            });

            const endpoint = await client.webhookEndpoints.create({
              status: 'enabled',
              url: 'https://example.com/webhook',
              subscriptions: [
                { event_type: 'activity/item_created' },
                { event_type: 'activity/item_mentioned' },
              ],
            });

            console.log(endpoint.id);
        - lang: Python
          source: |-
            import os
            from moonbase import Moonbase

            client = Moonbase(
                api_key=os.environ.get("MOONBASE_API_KEY"),  # This is the default and can be omitted
            )
            endpoint = client.webhook_endpoints.create(
                status="enabled",
                url="https://example.com/webhook",
                subscriptions=[{
                    "event_type": "activity/item_created"
                }, {
                    "event_type": "activity/item_mentioned"
                }],
            )
            print(endpoint.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/moonbaseai/moonbase-sdk-go\"\n\t\"github.com/moonbaseai/moonbase-sdk-go/option\"\n)\n\nfunc main() {\n\tclient := moonbase.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tendpoint, err := client.WebhookEndpoints.New(context.TODO(), moonbase.WebhookEndpointNewParams{\n\t\tStatus: moonbase.WebhookEndpointNewParamsStatusEnabled,\n\t\tURL:    \"https://example.com/webhook\",\n\t\tSubscriptions: []moonbase.WebhookEndpointNewParamsSubscription{{\n\t\t\tEventType: \"activity/item_created\",\n\t\t}, {\n\t\t\tEventType: \"activity/item_mentioned\",\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", endpoint.ID)\n}\n"
        - lang: Ruby
          source: >-
            require "moonbase"


            moonbase = Moonbase::Client.new(api_key: "My API Key")


            endpoint = moonbase.webhook_endpoints.create(status: :enabled, url:
            "https://example.com/webhook")


            puts(endpoint)
components:
  schemas:
    WebhookEndpointCreateParams:
      title: WebhookEndpointCreateParams
      description: Parameters for creating a webhook endpoint.
      type: object
      properties:
        url:
          description: The HTTPS URL where webhook events will be sent.
          type: string
        status:
          description: Indicates whether the endpoint is enabled.
          type: string
          enum:
            - disabled
            - enabled
        subscriptions:
          description: >-
            An array of event types that this endpoint should receive
            notifications for.
          type: array
          items:
            $ref: '#/components/schemas/WebhookSubscriptionCreateParams'
      required:
        - url
        - status
    WebhookEndpoint:
      title: WebhookEndpoint
      description: >-
        A Webhook Endpoint is an HTTP endpoint that receives webhooks. You can
        configure which events are sent to each endpoint by creating
        `WebhookSubscription` objects.
      type: object
      properties:
        type:
          description: >-
            String representing the object’s type. Always `webhook_endpoint` for
            this object.
          type: string
          const: webhook_endpoint
        id:
          description: Unique identifier for the object.
          type: string
        url:
          description: The HTTPS URL where webhook events will be sent.
          type: string
        status:
          description: Indicates whether the endpoint is enabled.
          type: string
          enum:
            - disabled
            - enabled
        secret:
          description: >-
            The signing secret used to verify webhook authenticity. This value
            is only shown when creating the endpoint and starts with `whsec_`.
          type: string
        subscriptions:
          description: >-
            An array of `WebhookSubscription` objects representing the events
            this endpoint will receive.
          type: array
          items:
            $ref: '#/components/schemas/WebhookSubscription'
        created_at:
          description: >-
            Time at which the object was created, as an ISO 8601 timestamp in
            UTC.
          type: string
          format: date-time
        updated_at:
          description: >-
            Time at which the object was last updated, as an ISO 8601 timestamp
            in UTC.
          type: string
          format: date-time
      required:
        - url
        - status
        - type
        - id
        - subscriptions
        - created_at
        - updated_at
    Errors:
      title: Errors
      description: >-
        The Errors object is a container that holds multiple Error objects when
        an API request encounters several validation or processing issues. This
        allows the API to return comprehensive feedback about all problems
        encountered in a single response.
      type: object
      properties:
        type:
          type: string
          const: errors
        errors:
          description: A list of `Error` objects.
          type: array
          items:
            $ref: '#/components/schemas/Error'
      required:
        - type
    WebhookSubscriptionCreateParams:
      title: WebhookSubscriptionCreateParams
      description: Parameters for creating a webhook subscription.
      type: object
      properties:
        event_type:
          description: >-
            The type of event that will trigger notifications to the endpoint
            (e.g., `activity/item_created`).
          type: string
          enum:
            - activity/call_occurred
            - activity/form_submitted
            - activity/inbox_message_sent
            - activity/item_created
            - activity/item_mentioned
            - activity/item_merged
            - activity/file_created
            - activity/meeting_held
            - activity/meeting_scheduled
            - activity/note_created
            - activity/program_message_bounced
            - activity/program_message_clicked
            - activity/program_message_complained
            - activity/program_message_failed
            - activity/program_message_opened
            - activity/program_message_sent
            - activity/program_message_shielded
            - activity/program_message_unsubscribed
      required:
        - event_type
    WebhookSubscription:
      title: WebhookSubscription
      description: >-
        A Webhook Subscription defines which event type should be sent to a
        specific webhook endpoint.
      type: object
      properties:
        type:
          description: >-
            String representing the object’s type. Always `webhook_subscription`
            for this object.
          type: string
          const: webhook_subscription
        event_type:
          description: >-
            The type of event that will trigger notifications to the endpoint
            (e.g., `activity/item_created`).
          type: string
          enum:
            - activity/call_occurred
            - activity/form_submitted
            - activity/inbox_message_sent
            - activity/item_created
            - activity/item_mentioned
            - activity/item_merged
            - activity/file_created
            - activity/meeting_held
            - activity/meeting_scheduled
            - activity/note_created
            - activity/program_message_bounced
            - activity/program_message_clicked
            - activity/program_message_complained
            - activity/program_message_failed
            - activity/program_message_opened
            - activity/program_message_sent
            - activity/program_message_shielded
            - activity/program_message_unsubscribed
      required:
        - event_type
        - type
    Error:
      title: Error
      description: >-
        The Error object represents a single error that occurred during API
        request processing. It provides detailed information about what went
        wrong, including a unique identifier, status code, and human-readable
        descriptions to help developers understand and resolve the issue.
      type: object
      properties:
        type:
          type: string
          const: error
        id:
          description: A unique identifier for this specific error instance.
          type: string
        status:
          description: The HTTP status code for this problem, as a string.
          type: string
        code:
          description: An application-specific error code string.
          type: string
        title:
          description: A short, human-readable summary of the problem.
          type: string
        detail:
          description: A human-readable explanation of this specific error.
          type: string
        source:
          $ref: '#/components/schemas/ErrorSource'
          description: >-
            An object containing more specific information about the part of the
            request that caused the error.
        meta:
          type: object
          additionalProperties: true
      required:
        - type
    ErrorSource:
      title: ErrorSource
      description: >-
        The ErrorSource object provides additional context about the specific
        part of an API request that caused an error. It can point to either a
        field in the request document or a query parameter that contains invalid
        data.
      type: object
      properties:
        pointer:
          description: >-
            A JSON Pointer [RFC6901] to the associated entity in the request
            document.
          type: string
        parameter:
          description: A string indicating which URI query parameter caused the error.
          type: string
      required: []
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: Your Moonbase API key.

````