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

# Block contact

> Block incoming calls and messages from a phone number across an account.



## OpenAPI

````yaml POST /accounts/{account_id}/blocked_contacts
openapi: 3.1.1
info:
  title: Surge
  version: '1.0'
servers:
  - url: https://api.surge.app
security:
  - authorization: []
paths:
  /accounts/{account_id}/blocked_contacts:
    post:
      tags:
        - Blocked contacts
      summary: Block a contact
      description: >
        Blocks incoming calls handled by Surge and incoming SMS/MMS from a phone
        number

        across the account. Direct SIP-trunk and AI-agent SIP calls are not
        currently filtered.

        Phone numbers are normalized to E.164. Short codes and alphanumeric
        sender IDs are not supported.


        Blocks are independent of regular contacts and outbound messaging
        consent.

        Repeated requests return the existing block without changing its reason
        or creation time.


        Blocked messages do not trigger ordinary inbox activity or
        message.received webhooks.

        They retain a metadata-only receipt and count toward normal inbound
        messaging usage.

        Consent keywords such as STOP and START still update messaging consent
        and retain

        their keyword replies and contact.opted_in/contact.opted_out webhooks.


        Blocked calls remain in call history and emit call.ended with status
        blocked and duration zero.

        These calls contribute zero billable minutes.
      operationId: CreateBlockedContact
      parameters:
        - in: path
          name: account_id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BlockedContactParams'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockedContact'
          description: Existing block
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockedContact'
          description: Created block
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Surge from '@surgeapi/node';


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


            const blockedContact = await
            client.blockedContacts.create('account_id', {
              phone_number: '+18015551234',
            });


            console.log(blockedContact.id);
        - lang: Python
          source: |-
            import os
            from surge import Surge

            client = Surge(
                api_key=os.environ.get("SURGE_API_KEY"),  # This is the default and can be omitted
            )
            blocked_contact = client.blocked_contacts.create(
                account_id="account_id",
                phone_number="+18015551234",
            )
            print(blocked_contact.id)
        - lang: Ruby
          source: >-
            require "surge_api"


            surge = SurgeAPI::Client.new(api_key: "My API Key")


            blocked_contact = surge.blocked_contacts.create("account_id",
            phone_number: "+18015551234")


            puts(blocked_contact)
components:
  schemas:
    BlockedContactParams:
      title: BlockedContactParams
      description: A phone number to block and an optional reason.
      properties:
        phone_number:
          description: The phone number to block. Stored in normalized E.164 format.
          example: '+18015551234'
          type: string
        reason:
          description: An optional explanation for the block.
          maxLength: 255
          type:
            - string
            - 'null'
      required:
        - phone_number
      type: object
    BlockedContact:
      title: BlockedContact
      description: An account-level block on incoming communication from a phone number.
      properties:
        created_at:
          description: When the block was created.
          format: date-time
          type: string
        id:
          description: Unique identifier for the block.
          type: string
        phone_number:
          description: The blocked phone number in E.164 format.
          example: '+18015551234'
          format: phone-number
          pattern: ^\+[1-9]\d{6,14}$
          type: string
        reason:
          description: An optional explanation for the block.
          maxLength: 255
          type:
            - string
            - 'null'
      required:
        - id
        - phone_number
        - reason
        - created_at
      type: object
    ErrorResponse:
      title: ErrorResponse
      description: An error response
      example:
        error:
          message: The requested resource could not be found.
          type: not_found
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
      type: object
    Error:
      title: Error
      description: An error response
      example:
        message: The requested resource was not found.
        type: not_found
      properties:
        detail:
          additionalProperties: true
          description: Additional details about the error.
          type: object
        message:
          description: A human-readable error message.
          example: The requested resource was not found.
          type: string
        type:
          description: A unique error code.
          example: not_found
          type: string
      required:
        - type
        - message
      type: object
  securitySchemes:
    authorization:
      bearerFormat: Surge API token
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.