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

# Block Customer

> Add a customer to your blocklist by customer ID or email address.



## OpenAPI

````yaml post /blocklist/customers
openapi: 3.1.0
info:
  title: public
  description: ''
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 1.120.20
servers:
  - url: https://test.dodopayments.com/
    description: Test Mode Server Host
  - url: https://live.dodopayments.com/
    description: Live Mode Server Host
security: []
tags:
  - name: Products
  - name: Payments
  - name: Subscriptions
  - name: Addons
  - name: Customers
  - name: Refunds
  - name: Disputes
  - name: Events
  - name: License Keys
  - name: Entitlements
  - name: Licenses
  - name: Discounts
  - name: Meters
  - name: Credit Entitlements
  - name: Credit Entitlement Balances
  - name: Outgoing Webhooks
  - name: Checkout
  - name: Webhook Events
  - name: Payment Connector Webhooks
  - name: Moderation
  - name: Locales
paths:
  /blocklist/customers:
    post:
      tags:
        - Blocklist
      operationId: create_blocked_customer
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBlockedCustomerRequest'
        required: true
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockedCustomerResponse'
        '404':
          description: No customer matches the identifier
        '409':
          description: The customer is already blocked
        '422':
          description: Invalid Request Object or Parameters
      security:
        - API_KEY: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import DodoPayments from 'dodopayments';


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


            const blockedCustomer = await client.blocklist.customers.create({
            customer_id: 'customer_id' });


            console.log(blockedCustomer.id);
        - lang: Python
          source: |-
            import os
            from dodopayments import DodoPayments

            client = DodoPayments(
                bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"),  # This is the default and can be omitted
            )
            blocked_customer = client.blocklist.customers.create(
                customer_id="customer_id",
            )
            print(blocked_customer.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/dodopayments/dodopayments-go\"\n\t\"github.com/dodopayments/dodopayments-go/option\"\n)\n\nfunc main() {\n\tclient := dodopayments.NewClient(\n\t\toption.WithBearerToken(\"My Bearer Token\"),\n\t)\n\tblockedCustomer, err := client.Blocklist.Customers.New(context.TODO(), dodopayments.BlocklistCustomerNewParams{\n\t\tCreateBlockedCustomerRequest: dodopayments.CreateBlockedCustomerRequestBlocklistCustomersBlockByCustomerIDParam(dodopayments.CreateBlockedCustomerRequestBlocklistCustomersBlockByCustomerIDParam{\n\t\t\tBlockByCustomerIDParam: dodopayments.BlockByCustomerIDParam{\n\t\t\t\tCustomerID: dodopayments.F(\"customer_id\"),\n\t\t\t},\n\t\t}),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", blockedCustomer.ID)\n}\n"
        - lang: Java
          source: >-
            package com.dodopayments.api.example;


            import com.dodopayments.api.client.DodoPaymentsClient;

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient;

            import
            com.dodopayments.api.models.blocklist.customers.BlockedCustomer;

            import
            com.dodopayments.api.models.blocklist.customers.CreateBlockedCustomerRequest;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    DodoPaymentsClient client = DodoPaymentsOkHttpClient.fromEnv();

                    CreateBlockedCustomerRequest.BlocklistCustomersBlockByCustomerId params = CreateBlockedCustomerRequest.BlocklistCustomersBlockByCustomerId.builder()
                        .customerId("customer_id")
                        .build();
                    BlockedCustomer blockedCustomer = client.blocklist().customers().create(params);
                }
            }
        - lang: Kotlin
          source: >-
            package com.dodopayments.api.example


            import com.dodopayments.api.client.DodoPaymentsClient

            import com.dodopayments.api.client.okhttp.DodoPaymentsOkHttpClient

            import
            com.dodopayments.api.models.blocklist.customers.BlockedCustomer

            import
            com.dodopayments.api.models.blocklist.customers.CreateBlockedCustomerRequest


            fun main() {
                val client: DodoPaymentsClient = DodoPaymentsOkHttpClient.fromEnv()

                val params: CreateBlockedCustomerRequest.BlocklistCustomersBlockByCustomerId = CreateBlockedCustomerRequest.BlocklistCustomersBlockByCustomerId.builder()
                    .customerId("customer_id")
                    .build()
                val blockedCustomer: BlockedCustomer = client.blocklist().customers().create(params)
            }
        - lang: Ruby
          source: >-
            require "dodopayments"


            dodo_payments = Dodopayments::Client.new(
              bearer_token: "My Bearer Token",
              environment: "test_mode" # defaults to "live_mode"
            )


            blocked_customer =
            dodo_payments.blocklist.customers.create(create_blocked_customer_request:
            {customer_id: "customer_id"})


            puts(blocked_customer)
        - lang: PHP
          source: |-
            <?php

            require_once dirname(__DIR__) . '/vendor/autoload.php';

            use Dodopayments\Client;
            use Dodopayments\Blocklist\Customers\BlockedCustomerSource;
            use Dodopayments\Core\Exceptions\APIException;

            $client = new Client(
              bearerToken: getenv('DODO_PAYMENTS_API_KEY') ?: 'My Bearer Token',
              environment: 'test_mode',
            );

            try {
              $blockedCustomer = $client->blocklist->customers->create(
                customerID: 'customer_id',
                reason: 'reason',
                source: BlockedCustomerSource::BLOCKLIST_PAGE,
                email: 'email',
              );

              var_dump($blockedCustomer);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: >-
            using System;

            using DodoPayments.Client;

            using DodoPayments.Client.Models.Blocklist.Customers;


            DodoPaymentsClient client = new();


            CustomerCreateParams parameters = new()

            {
                CreateBlockedCustomerRequest = new BlocklistCustomersBlockByCustomerID()
                {
                    CustomerID = "customer_id",
                    Reason = "reason",
                    Source = BlockedCustomerSource.BlocklistPage,
                },
            };


            var blockedCustomer = await
            client.Blocklist.Customers.Create(parameters);


            Console.WriteLine(blockedCustomer);
        - lang: Rust
          source: |-
            use dodopayments::Client;

            #[tokio::main]
            async fn main() -> dodopayments::Result<()> {
                let client = Client::from_env()?;
                let result = client
                    .blocklist()
                    .customers()
                    .create()
                    .body(serde_json::json!({"customer_id":"customer_id","reason":"reason","source":"blocklist_page"}))
                    .await?;
                println!("{result:?}");
                Ok(())
            }
components:
  schemas:
    CreateBlockedCustomerRequest:
      allOf:
        - $ref: '#/components/schemas/BlockIdentifier'
        - type: object
          properties:
            reason:
              type:
                - string
                - 'null'
              description: Why the merchant blocked this customer. The entry page shows it.
            source:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/BlockedCustomerSource'
                  description: >-
                    Screen the merchant blocked from. Ignored for an API-key
                    caller, whose

                    entry always records `api`. A dashboard caller that omits it
                    records

                    `blocklist_page`.
    BlockedCustomerResponse:
      type: object
      required:
        - id
        - customer_id
        - customer_name
        - customer_email
        - identifier
        - source
        - created_at
      properties:
        blocked_by_email:
          type:
            - string
            - 'null'
          description: >-
            Dashboard user who blocked the customer. `null` for an API-key
            caller.
        cancelled_subscription_ids:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Subscriptions this block cancelled. Present on the create response
            only.
        created_at:
          type: string
          format: date-time
        customer_email:
          type: string
        customer_id:
          type: string
        customer_name:
          type: string
        id:
          type: string
        identifier:
          type: string
          description: Customer id or email that the merchant supplied.
        notes:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/BlockedCustomerNote'
          description: Activity log. Present on the detail response only.
        reason:
          type:
            - string
            - 'null'
        remaining_subscription_ids:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Subscriptions this block left live, because the cancel failed or the

            inline batch filled up. Repeat the create call to continue; the
            block

            itself is already in force.
        source:
          $ref: '#/components/schemas/BlockedCustomerSource'
        subscriptions_swept:
          type:
            - boolean
            - 'null'
          description: >-
            False when the block left live subscriptions behind, including the
            case

            where the sweep could not list them and `remaining_subscription_ids`
            is

            therefore unknown. Repeat the create call until it reads true.
        unblocked_at:
          type:
            - string
            - 'null'
          format: date-time
    BlockIdentifier:
      oneOf:
        - $ref: '#/components/schemas/BlockByCustomerId'
        - $ref: '#/components/schemas/BlockByEmail'
      description: >-
        Which customer to block. Untagged, so the caller sends `customer_id` or

        `email` at the top level, as `CustomerRequest` does on the payment
        routes.

        A body that carries both matches the first variant, so `customer_id`
        wins.
    BlockedCustomerSource:
      type: string
      description: |-
        Where a block came from. `Api` marks an API-key caller, which carries no
        dashboard actor. The other values name the screen the merchant used.
      enum:
        - blocklist_page
        - customer_page
        - payment_page
        - dispute_page
        - api
    BlockedCustomerNote:
      type: object
      required:
        - id
        - note
        - created_at
      properties:
        author_email:
          type:
            - string
            - 'null'
        created_at:
          type: string
          format: date-time
        id:
          type: string
        note:
          type: string
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
    BlockByCustomerId:
      type: object
      required:
        - customer_id
      properties:
        customer_id:
          type: string
          description: Customer to block. The block still applies to that customer's email.
    BlockByEmail:
      type: object
      required:
        - email
      properties:
        email:
          type: string
          description: >-
            Email to block. It must belong to an existing customer of this
            business.
  securitySchemes:
    API_KEY:
      type: http
      scheme: bearer

````

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