> ## 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 Unsubscribe

> Create a new unsubscribe.



## OpenAPI

````yaml POST /unsubscribes
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:
  /unsubscribes:
    post:
      tags:
        - Marketing
      summary: Create an unsubscribe
      description: Create a new unsubscribe.
      parameters: []
      requestBody:
        description: The `email` for the unsubscribe.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UnsubscribeCreateParams'
            examples:
              Create unsubscribe:
                summary: Create unsubscribe
                value:
                  email: yoda@moonbase.ai
      responses:
        '201':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unsubscribe'
              examples:
                Create unsubscribe:
                  summary: Create unsubscribe
                  value:
                    type: unsubscribe
                    email: yoda@moonbase.ai
                    created_at: '2025-02-17T16:00:00.000Z'
        '400':
          description: Bad request. Invalid payload or required fields are missing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Missing email:
                  summary: Missing email
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '400'
                        title: Bad Request
                        detail: >-
                          Request body invalid: object at root is missing
                          required properties: email
        '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: Validation failed. The email is invalid or already unsubscribed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Invalid email:
                  summary: Invalid email
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '422'
                        title: Unprocessable Entity
                        detail: Email is invalid
                        source:
                          pointer: /email
                Duplicate email:
                  summary: Duplicate email
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '422'
                        title: Unprocessable Entity
                        detail: Email has already been taken
                        source:
                          pointer: /email
        '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 unsubscribe = await client.unsubscribes.create({ email:
            'yoda@moonbase.ai' });


            console.log(unsubscribe.created_at);
        - 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
            )
            unsubscribe = client.unsubscribes.create(
                email="yoda@moonbase.ai",
            )
            print(unsubscribe.created_at)
        - 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\tunsubscribe, err := client.Unsubscribes.New(context.TODO(), moonbase.UnsubscribeNewParams{\n\t\tEmail: \"yoda@moonbase.ai\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", unsubscribe.CreatedAt)\n}\n"
        - lang: Ruby
          source: >-
            require "moonbase"


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


            unsubscribe = moonbase.unsubscribes.create(email:
            "yoda@moonbase.ai")


            puts(unsubscribe)
components:
  schemas:
    UnsubscribeCreateParams:
      title: UnsubscribeCreateParams
      description: ''
      type: object
      properties:
        email:
          type: string
      required:
        - email
    Unsubscribe:
      title: Unsubscribe
      description: A record of an unsubscribed email address.
      type: object
      properties:
        type:
          type: string
          const: unsubscribe
        email:
          type: string
          format: email
        created_at:
          type: string
          format: date-time
      required:
        - email
        - type
        - created_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
    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.

````