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 →
400Returns202with the import record (statuspending); an Oban worker (EmailBlockImportWorker, max_attempts 3) transitionspending → processing → completed | failed.
Native Telnyx exports are detected by the stable first-12-column
header signature (id … group_id) and are restored with their
original from, domain_id, group_id, source, status,
expires_at, plus bounce_category, dsn_code, and meta when
present (scope is re-derived from domain_id/from; the
exported scope cell must be a valid enum value). Lifecycle
changes reconcile through the same create path as the API: a row
already in the requested state restores its mutable backup fields
without a new audit event, and a real transition (e.g. tombstone
→ active) appends the matching lifecycle event. block_ttl_days
is not applied to native rows — their exported expires_at is
preserved verbatim.
Competitor and generic imports (SendGrid / Mailgun / SES /
generic) remain account-scoped (from, domain_id, group_id,
scope are not read) and 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).
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.imports.create();
console.log(EmailBlockImport.data);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.imports.create()
print(email_block_import.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
import, err := client.EmailBlocks.Imports.New(
context.TODO(),
telnyx.EmailBlockImportNewParams{
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", import.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.emailBlocks.imports.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().imports().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
email_block_import = telnyx.email_blocks.imports.create
puts(email_block_import)<?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->imports->create();
var_dump($email_block_import);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-blocks:imports create \
--api-key 'My API Key'curl --request POST \
--url https://api.telnyx.com/v2/email_blocks/import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form block_ttl_days=30{
"data": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"record_type": "email_block_import",
"status": "pending",
"total": 0,
"provider": "sendgrid",
"created_at": "2024-01-23T18:10:02.574Z",
"updated_at": "2024-01-23T18:10:02.574Z",
"completed_at": "2024-01-23T18:10:02.574Z",
"processed_rows": 0,
"created_count": 0,
"existing_count": 0,
"skipped_count": 0,
"error_count": 0,
"failure_reason": "string"
}
}{
"errors": [
{
"code": "10015",
"title": "Validation Failed",
"detail": "is invalid",
"source": {
"pointer": "/filter[reason]"
}
}
]
}{
"errors": [
{
"code": "10007",
"title": "Unauthorized",
"detail": "Missing authentication"
}
]
}{
"errors": [
{
"code": "406",
"title": "Not Acceptable",
"detail": "Not Acceptable"
}
]
}{
"errors": [
{
"code": "10007",
"title": "Unexpected error",
"detail": "An unexpected error occured."
}
]
}{
"errors": [
{
"code": "10015",
"title": "Validation Failed",
"detail": "can't be blank",
"source": {
"pointer": "/data/attributes/to"
}
}
]
}{
"errors": [
{
"code": "10007",
"title": "Unexpected error",
"detail": "An unexpected error occured."
}
]
}Authorizations
Telnyx API key supplied as Authorization: Bearer <token>. In production, auth may be validated by the API gateway and forwarded via Telnyx auth headers.
Body
Response
Import job accepted (status pending).
Import job. Schema fields hidden: account_id, csv_content,
block_ttl_days. Nullable fields use the omit-nullable pattern.
Show child attributes
Show child attributes
Was this page helpful?
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.imports.create();
console.log(EmailBlockImport.data);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.imports.create()
print(email_block_import.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
import, err := client.EmailBlocks.Imports.New(
context.TODO(),
telnyx.EmailBlockImportNewParams{
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", import.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.emailBlocks.imports.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().imports().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
email_block_import = telnyx.email_blocks.imports.create
puts(email_block_import)<?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->imports->create();
var_dump($email_block_import);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx email-blocks:imports create \
--api-key 'My API Key'curl --request POST \
--url https://api.telnyx.com/v2/email_blocks/import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form block_ttl_days=30{
"data": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"record_type": "email_block_import",
"status": "pending",
"total": 0,
"provider": "sendgrid",
"created_at": "2024-01-23T18:10:02.574Z",
"updated_at": "2024-01-23T18:10:02.574Z",
"completed_at": "2024-01-23T18:10:02.574Z",
"processed_rows": 0,
"created_count": 0,
"existing_count": 0,
"skipped_count": 0,
"error_count": 0,
"failure_reason": "string"
}
}{
"errors": [
{
"code": "10015",
"title": "Validation Failed",
"detail": "is invalid",
"source": {
"pointer": "/filter[reason]"
}
}
]
}{
"errors": [
{
"code": "10007",
"title": "Unauthorized",
"detail": "Missing authentication"
}
]
}{
"errors": [
{
"code": "406",
"title": "Not Acceptable",
"detail": "Not Acceptable"
}
]
}{
"errors": [
{
"code": "10007",
"title": "Unexpected error",
"detail": "An unexpected error occured."
}
]
}{
"errors": [
{
"code": "10015",
"title": "Validation Failed",
"detail": "can't be blank",
"source": {
"pointer": "/data/attributes/to"
}
}
]
}{
"errors": [
{
"code": "10007",
"title": "Unexpected error",
"detail": "An unexpected error occured."
}
]
}