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

# Create an async CSV import job

> Accepts `multipart/form-data` with a `file` field (the CSV) and an
optional `block_ttl_days` (integer >0, default 30). Validates:
  - content ≤ 25 MiB, else `413`
  - row count ≤ 250 000, else `413`
  - header-only / all-blank / undetectable provider → `400`
Returns `202` with the import record (status `pending`); an Oban
worker (`EmailBlockImportWorker`, max_attempts 3) transitions
`pending → processing → completed | failed`. `block_ttl_days`
applies only to imported `manual_block` rows; other reasons get
`expires_at: nil`. Provider is auto-detected from the CSV header
(`sendgrid` / `mailgun` / `ses` / `generic`).




## OpenAPI

````yaml /openapi/generated/email/suppressions.yml post /email_blocks/import
openapi: 3.1.0
info:
  contact:
    email: support@telnyx.com
  description: API for managing email suppression blocks (bounce, complaint, manual).
  title: Telnyx Email Suppressions API
  version: 2.0.0
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /email_blocks/import:
    post:
      tags:
        - Email Suppression Imports
      summary: Create an async CSV import job
      description: |
        Accepts `multipart/form-data` with a `file` field (the CSV) and an
        optional `block_ttl_days` (integer >0, default 30). Validates:
          - content ≤ 25 MiB, else `413`
          - row count ≤ 250 000, else `413`
          - header-only / all-blank / undetectable provider → `400`
        Returns `202` with the import record (status `pending`); an Oban
        worker (`EmailBlockImportWorker`, max_attempts 3) transitions
        `pending → processing → completed | failed`. `block_ttl_days`
        applies only to imported `manual_block` rows; other reasons get
        `expires_at: nil`. Provider is auto-detected from the CSV header
        (`sendgrid` / `mailgun` / `ses` / `generic`).
      operationId: createEmailBlockImport
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateImportRequest'
      responses:
        '202':
          description: Import job accepted (status `pending`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmailBlockImportResponse'
        '400':
          $ref: '#/components/responses/ValidationErrorQuery'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '406':
          $ref: '#/components/responses/FrameworkError'
        '413':
          description: |
            Two distinct 413 paths. Content-level cap (decoded CSV > 25 MiB
            or > 250 000 rows) returns `10015` with `source.pointer /file`.
            The multipart parser raises `RequestTooLargeError` when the
            encoded body exceeds 26 MiB — that's a framework error rendered
            with body `code: "413"` (matches the HTTP status).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorList'
        '422':
          $ref: '#/components/responses/ChangesetError'
        '500':
          description: Import-create fallback (`code 10019`, "Failed to create import").
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorList'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

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

            const EmailBlockImport = await client.emailBlocks.import.create();

            console.log(EmailBlockImport.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            email_block_import = client.email_blocks.import.create()
            print(email_block_import.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\timport, err := client.EmailBlocks.Import.New(\n\t\tcontext.TODO(),\n\t\ttelnyx.EmailBlockImportNewParams{\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", import.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
            import com.telnyx.sdk.models.emailBlocks.import.ImportCreateParams;

            public final class Main {
                private Main() {}

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

                    ImportCreateParams params = ImportCreateParams.builder()
                        .build();
                    var response = client.emailBlocks().import().create(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            email_block_import = telnyx.email_blocks.import.create

            puts(email_block_import)
        - lang: PHP
          source: >-
            <?php


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


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $email_block_import = $client->emailBlocks->import->create();

              var_dump($email_block_import);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx email-blocks:import create \
              --api-key 'My API Key'
components:
  schemas:
    CreateImportRequest:
      type: object
      required:
        - file
      properties:
        file:
          type: string
          format: binary
          description: The CSV file (Plug.Upload). Missing/non-upload → 400.
        block_ttl_days:
          type: integer
          minimum: 1
          default: 30
          description: >-
            TTL for imported `manual_block` rows; other reasons get `expires_at:
            null`. Invalid/missing → falls back to 30.
    EmailBlockImportResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/EmailBlockImport'
    ErrorList:
      type: object
      required:
        - errors
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/BlocksErrorObject'
    EmailBlockImport:
      type: object
      required:
        - id
        - record_type
        - status
        - total
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        record_type:
          type: string
          enum:
            - email_block_import
          description: View-only.
        status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - failed
        total:
          type: integer
          description: Data-row count at upload.
        provider:
          type: string
          enum:
            - sendgrid
            - mailgun
            - ses
            - generic
          description: Omitted when nil.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        completed_at:
          type: string
          format: date-time
          description: Omitted until terminal success.
        processed_rows:
          type: integer
          description: Only when `status == completed`.
        created_count:
          type: integer
          description: Only when `status == completed`.
        existing_count:
          type: integer
          description: Only when `status == completed`.
        skipped_count:
          type: integer
          description: Only when `status == completed`.
        error_count:
          type: integer
          description: Only when `status == completed`.
        errors:
          type: object
          additionalProperties:
            type: string
          description: '`{row_number: reason}`; only rendered when non-empty.'
        failure_reason:
          type: string
          description: Only on terminal failure.
      description: |
        Import job. Schema fields hidden: `account_id`, `csv_content`,
        `block_ttl_days`. Nullable fields use the omit-nullable pattern.
    BlocksErrorObject:
      type: object
      required:
        - code
        - title
        - detail
      properties:
        code:
          type: string
          description: |
            Error codes: `10001` (Not Found), `10007` (Unauthorized),
            `10015` (Validation Failed), `10019` (Internal — import create
            fallback), `40901` (Conflict), `500` (framework/catch-all).
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              type: string
          description: >-
            `/data/attributes/<field>` for changeset/Params; `/<field>` for
            query-param errors.
  responses:
    ValidationErrorQuery:
      description: Query-param validation error (`source.pointer /<field>`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorList'
          example:
            errors:
              - code: '10015'
                title: Validation Failed
                detail: is invalid
                source:
                  pointer: /filter[reason]
    Unauthorized:
      description: Missing or invalid gateway auth.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorList'
          example:
            errors:
              - code: '10007'
                title: Unauthorized
                detail: Missing authentication
    FrameworkError:
      description: |
        Framework-rendered error (e.g. 406 Not Acceptable, 405 Method Not
        Allowed, 415 Unsupported Media Type). HTTP status matches the error
        and the body `code` carries that same status (e.g. `"406"`, not a
        hardcoded `"500"`). The explicit `500.json` clause still emits
        `code: "500"` for genuine 500s.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorList'
          example:
            errors:
              - code: '406'
                title: Not Acceptable
                detail: Not Acceptable
    ChangesetError:
      description: >-
        Validation error (changeset or internal `Params`). One error object per
        field, `source.pointer /data/attributes/<field>`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorList'
          example:
            errors:
              - code: '10015'
                title: Validation Failed
                detail: can't be blank
                source:
                  pointer: /data/attributes/to
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````