Lob.com Self Mailers API

The self mailer endpoint allows you to easily print and mail self mailers. The API provides endpoints for creating self mailers, retrieving individual self mailers, canceling self mailers, and retrieving a list of self mailers. back to top

OpenAPI Specification

lobcom-self-mailers-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Lob Self Mailers API
  version: 1.22.0
  description: 'The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors. <p>

    '
  license:
    name: MIT
    url: https://mit-license.org/
  contact:
    name: Lob Developer Experience
    url: https://support.lob.com/
    email: lob-openapi@lob.com
  termsOfService: https://www.lob.com/legal
servers:
- url: https://api.lob.com/v1
  description: production
security:
- basicAuth: []
tags:
- name: Self Mailers
  description: 'The self mailer endpoint allows you to easily print and mail self mailers. The API provides endpoints

    for creating self mailers, retrieving individual self mailers, canceling self mailers, and retrieving a list of self mailers.

    <div class="back-to-top" ><a href="#" onclick="toTopLink()">back to top</a></div>

    '
paths:
  /self_mailers/{sfm_id}:
    parameters:
    - in: path
      name: sfm_id
      description: id of the self_mailer
      required: true
      schema:
        $ref: '#/components/schemas/sfm_id'
    get:
      operationId: self_mailer_retrieve
      summary: Retrieve
      description: Retrieves the details of an existing self_mailer. You need only supply the unique self_mailer identifier that was returned upon self_mailer creation.
      tags:
      - Self Mailers
      responses:
        '200':
          description: Returns a self_mailer object
          content:
            $ref: '#/components/mediaTypes/self_mailer'
        default:
          $ref: '#/components/responses/mailpiece_error'
      x-codeSamples:
      - lang: Shell
        source: "curl -X GET \"https://api.lob.com/v1/self_mailers/sfm_8ffbe811dea49dcf\" \\\n  -u REDACTED_LOB_KEY:\n"
        label: CURL
      - lang: typescript
        source: "try {\n  const selfMailer = await new SelfMailersApi(config).get('sfm_xxxx');\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: "Lob.selfMailers.retrieve('sfm_8ffbe811dea49dcf', function (err, res) {\n  console.log(err, res);\n});\n"
        label: NODE
      - lang: Ruby
        source: "selfMailerApi = SelfMailersApi.new(config)\n\nbegin\n  retrievedSelfMailer = selfMailerApi.get(\"sfm_8ffbe811dea49dcf\")\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = SelfMailersApi(api_client)\n\ntry:\n  self_mailer = api.get(\"sfm_8ffbe811dea49dcf\")\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\SelfMailersApi($config, new GuzzleHttp\\Client());\n\ntry {\n    $result = $apiInstance->get(\"sfm_8ffbe811dea49dcf\");\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "SelfMailersApi apiInstance = new SelfMailersApi(config);\n\ntry {\n  SelfMailer response = apiInstance.get(\"sfm_8ffbe811dea49dcf\");\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'Lob.SelfMailer.find("sfm_8ffbe811dea49dcf")

          '
        label: ELIXIR
      - lang: CSharp
        source: "SelfMailersApi api = new SelfMailersApi(config);\n\ntry {\n  SelfMailer response = api.get(\"sfm_8ffbe811dea49dcf\");\n} catch (ApiException e) {\n  Console.WriteLine(e.ToString());\n}\n"
        label: CSHARP
      - lang: Go
        source: "var context = context.Background()\ncontext = context.WithValue(suite.ctx, lob.ContextBasicAuth, lob.BasicAuth{UserName: os.Getenv(\"<YOUR_API_KEY>\")})\n\nvar apiClient = *lob.NewAPIClient(configuration)\n\nfetchedSelfMailer, _, err := apiClient.SelfMailersApi.Get(context,\"sfm_8ffbe811dea49dcf\").Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
    delete:
      operationId: self_mailer_delete
      summary: Delete
      description: Completely removes a self mailer from production. This can only be done if the self mailer's `send_date` has not yet passed. If the self mailer is successfully canceled, you will not be charged for it. This feature is exclusive to certain customers. Upgrade to the appropriate <a href="https://dashboard.lob.com/#/settings/editions" target="_blank">Print & Mail Edition</a> to gain access.
      tags:
      - Self Mailers
      responses:
        '200':
          $ref: '#/components/responses/self_mailer_deleted'
        default:
          $ref: '#/components/responses/mailpiece_error'
      x-codeSamples:
      - lang: Shell
        source: "curl -X DELETE https://api.lob.com/v1/self_mailers/sfm_8ffbe811dea49dcf \\\n  -u REDACTED_LOB_KEY:\n"
        label: CURL
      - lang: typescript
        source: "try {\n  const deleteSelfMailer = await new SelfMailersApi(config).cancel('sfm_xxxx');\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: "Lob.selfMailers.cancel('sfm_8ffbe811dea49dcf', function (err, res) {\n  console.log(err, res);\n});\n"
        label: NODE
      - lang: Ruby
        source: "selfMailerApi = SelfMailersApi.new(config)\n\nbegin\n  deletedSelfMailer = selfMailerApi.cancel(\"sfm_8ffbe811dea49dcf\")\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = SelfMailersApi(api_client)\n\ntry:\n  deleted_resource = api.cancel(\"sfm_8ffbe811dea49dcf\")\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\SelfMailersApi($config, new GuzzleHttp\\Client());\n\ntry {\n    $result = $apiInstance->cancel(\"sfm_8ffbe811dea49dcf\");\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "SelfMailersApi apiInstance = new SelfMailersApi(config);\n\ntry {\n    SelfMailerDeletion response = apiInstance.cancel(\"sfm_8ffbe811dea49dcf\");\n} catch (ApiException e) {\n    e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'Lob.SelfMailer.destroy("sfm_8ffbe811dea49dcf")

          '
        label: ELIXIR
      - lang: CSharp
        source: "SelfMailersApi api = new SelfMailersApi(config);\n\ntry {\n  SelfMailerDeletion response = api.cancel(\"sfm_8ffbe811dea49dcf\");\n} catch (ApiException e) {\n  Console.WriteLine(e.ToString());\n}\n"
        label: CSHARP
      - lang: Go
        source: "var context = context.Background()\ncontext = context.WithValue(suite.ctx, lob.ContextBasicAuth, lob.BasicAuth{UserName: os.Getenv(\"<YOUR_API_KEY>\")})\n\nvar apiClient = *lob.NewAPIClient(configuration)\n\ndeletedSelfMailer, _, err := apiClient.SelfMailersApi.Cancel(context, \"sfm_8ffbe811dea49dcf\").Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
  /self_mailers:
    get:
      operationId: self_mailers_list
      summary: List
      description: Returns a list of your self_mailers. The self_mailers are returned sorted by creation date, with the most recently created self_mailers appearing first.
      tags:
      - Self Mailers
      parameters:
      - $ref: '#/components/parameters/limit'
      - $ref: '#/components/parameters/before_after'
      - $ref: '#/components/parameters/include'
      - $ref: '#/components/parameters/date_created'
      - $ref: '#/components/parameters/metadata'
      - in: query
        name: size
        description: The self mailer sizes to be returned.
        schema:
          type: array
          items:
            $ref: '#/components/schemas/self_mailer_size'
      - $ref: '#/components/parameters/scheduled'
      - $ref: '#/components/parameters/send_date'
      - $ref: '#/components/parameters/mail_type'
      - $ref: '#/components/parameters/sort_by'
      - $ref: '#/components/parameters/campaign_id'
      - $ref: '#/components/parameters/status'
      responses:
        '200':
          $ref: '#/components/responses/all_self_mailers'
        default:
          $ref: '#/components/responses/mailpiece_error'
      x-codeSamples:
      - lang: Shell
        source: "curl -X GET \"https://api.lob.com/v1/self_mailers?limit=2\" \\\n  -u REDACTED_LOB_KEY:\n"
        label: CURL
      - lang: typescript
        source: "try {\n  const selfMailers = await new selfMailersApi(config).list(2);\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: "Lob.selfMailers.list({limit: 2}, function (err, res) {\n  console.log(err, res);\n});\n"
        label: NODE
      - lang: Ruby
        source: "selfMailersApi = SelfMailersApi.new(config)\n\nbegin\n  selfMailers = selfMailersApi.list({ limit: 2 })\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = SelfMailersApi(api_client)\n\ntry:\n  self_mailers = api.list(limit=2)\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\SelfMailersApi($config, new GuzzleHttp\\Client());\n\ntry {\n    $result = $apiInstance->list(\n      2, // limit\n    );\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "SelfMailersApi apiInstance = new SelfMailersApi(config);\n\ntry {\n  SelfMailerList response = apiInstance.list(\n    2, // limit\n    null, // before\n    null, // after\n    null, // include\n    null, // dateCreated\n    null, // metadata\n    null, // size\n    null, // scheduled\n    null, // sendDate\n    null, // mailType\n    null // sortBy\n  );\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'Lob.SelfMailer.list(%{limit: 2})

          '
        label: ELIXIR
      - lang: CSharp
        source: "SelfMailersApi api = new SelfMailersApi(config);\n\nList<string> includeList = new List<string>();\nincludeList.Add(\"total_count\");\nDictionary<String, String> metadata = new Dictionary<String, String>();\nmetadata.Add(\"name\", \"Harry\");\nDictionary<String, DateTime> dateCreated = new Dictionary<String, DateTime>();\nDateTime dateCreatedDate = DateTime.Today.AddMonths(-1);\ndateCreated.Add(\"lt\", dateCreatedDate);\nDictionary<String, String> sendDate = new Dictionary<String, String>();\nsendDate.Add(\"lt\", DateTime.Now.ToString(\"yyyy-MM-ddTHH\\\\:mm\\\\:ss.fffffffzzz\"));\nSortBy3 sortBy = new SortBy3(SortBy3.DateCreatedEnum.Asc);\n\ntry {\n  SelfMailerList response = api.list(\n    2, // limit\n    null, // before\n    null, // after\n    includeList, // include\n    dateCreated, // dateCreated\n    metadata, // metadata\n    null, // size\n    true, // scheduled\n    sendDate, // sendDate\n    MailType.FirstClass, // mailType\n    sortBy // sortBy\n  );\n} catch (ApiException e) {\n  Console.WriteLine(e.ToString());\n}\n"
        label: CSHARP
      - lang: Go
        source: "var context = context.Background()\ncontext = context.WithValue(suite.ctx, lob.ContextBasicAuth, lob.BasicAuth{UserName: os.Getenv(\"<YOUR_API_KEY>\")})\n\nvar apiClient = *lob.NewAPIClient(configuration)\nSelfMailerList = apiClient.SelfMailersApi.List(context).Execute()\nif err != nil {\n    return err\n}\n"
        label: GO
    post:
      operationId: self_mailer_create
      summary: Create
      description: Creates a new self_mailer given information
      tags:
      - Self Mailers
      parameters:
      - $ref: '#/components/parameters/idem-header'
      - $ref: '#/components/parameters/idem-query'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/self_mailer_editable'
            example:
              description: Demo Self Mailer job
              to: adr_bae820679f3f536b
              from: adr_210a8d4b0b76d77b
              inside: https://lob.com/selfmailerinside.pdf
              outside: https://lob.com/selfmaileroutside.pdf
              size: 12x9_bifold
              metadata:
                spiffy: 'true'
              mail_type: usps_standard
              merge_variables:
                name: Harry
              send_date: '2017-11-01T00:00:00.000Z'
              use_type: marketing
              qr_code:
                position: relative
                redirect_url: https://www.lob.com
                width: '2.5'
                top: '2.5'
                right: '2.5'
                pages: inside,outside
              fsc: true
              print_speed: core
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/self_mailer_editable'
            example:
              description: Demo Self Mailer job
              to: adr_bae820679f3f536b
              from: adr_210a8d4b0b76d77b
              inside: https://lob.com/selfmailerinside.pdf
              outside: https://lob.com/selfmaileroutside.pdf
              size: 12x9_bifold
              metadata:
                spiffy: 'true'
              mail_type: usps_standard
              merge_variables:
                name: Harry
              send_date: '2017-11-01T00:00:00.000Z'
              use_type: marketing
              qr_code:
                position: relative
                redirect_url: https://www.lob.com
                width: '2.5'
                top: '2.5'
                right: '2.5'
                pages: inside,outside
              fsc: true
              print_speed: core
            encoding:
              merge_variables:
                style: deepObject
                explode: true
              metadata:
                style: deepObject
                explode: true
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/self_mailer_editable'
            example:
              description: Demo Self Mailer job
              to: adr_bae820679f3f536b
              from: adr_210a8d4b0b76d77b
              inside: https://lob.com/selfmailerinside.pdf
              outside: https://lob.com/selfmaileroutside.pdf
              size: 12x9_bifold
              metadata:
                spiffy: 'true'
              mail_type: usps_standard
              merge_variables:
                name: Harry
              send_date: '2017-11-01T00:00:00.000Z'
              use_type: marketing
              qr_code:
                position: relative
                redirect_url: https://www.lob.com
                width: '2.5'
                top: '2.5'
                right: '2.5'
                pages: inside,outside
              fsc: true
              print_speed: core
      responses:
        '200':
          $ref: '#/components/responses/post_self_mailer'
        default:
          $ref: '#/components/responses/mailpiece_error'
      x-codeSamples:
      - lang: Shell
        source: "curl https://api.lob.com/v1/self_mailers \\\n  -u REDACTED_LOB_KEY: \\\n  -d \"description=Demo Self Mailer job\" \\\n  -d \"to[name]=Harry Zhang\" \\\n  -d \"to[address_line1]=210 King St\" \\\n  -d \"to[address_city]=San Francisco\" \\\n  -d \"to[address_state]=CA\" \\\n  -d \"to[address_zip]=94107\" \\\n  -d \"from=adr_210a8d4b0b76d77b\" \\\n  -d \"use_type=marketing\" \\\n  -d 'qr_code[position]=relative' \\\n  -d 'qr_code[redirect_url]=https://www.lob.com' \\\n  -d 'qr_code[width]=2.5' \\\n  -d 'qr_code[bottom]=2.5' \\\n  -d 'qr_code[left]=2.5' \\\n  -d 'qr_code[pages]=inside,outside'\n  --data-urlencode \"inside=<html style='padding: 1in; font-size: 50;'>Inside HTML for {{name}}</html>\" \\\n  --data-urlencode \"outside=<html style='padding: 1in; font-size: 20;'>Outside HTML for {{name}}</html>\" \\\n  -d \"merge_variables[name]=Harry\" \\\n  -d 'fsc=true' \\\n  -d 'print_speed=core'\n"
        label: CURL
      - lang: Typescript
        source: "const selfMailerCreate = new SelfMailerEditable({\n  to: {\n  name: 'Harry Zhang',\n  address_line1: '210 King St',\n  address_line2: '# 6100',\n  address_city: 'San Francisco',\n  address_state: 'CA',\n  address_zip: '94107',\n},\n  from: 'adr_xxxx',\n  inside:\n  'https://s3.us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_inside.pdf',\n  outside:\n  'https://s3.us-west-2.amazonaws.com/public.lob.com/assets/templates/self_mailers/6x18_sfm_outside.pdf',\n  use_type: 'marketing'\n  qr_code : {\n    position: 'relative',\n    redirect_url: 'https://www.lob.com',\n    width: '2.5',\n    bottom: '2.5',\n    left: '2.5',\n    pages: 'inside'\n  },\n  fsc: true,\n  print_speed: 'core'\n});\n\ntry {\n  const mySelfMailer = await new SelfMailersApi(config).create(selfMailerCreate);\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: "Lob.selfMailers.create({\n  description: 'Demo Self Mailer job',\n  to: {\n    name: 'Harry Zhang',\n    address_line1: '210 King St',\n    address_city: 'San Francisco',\n    address_state: 'CA',\n    address_zip: '94107'\n  },\n  from: 'adr_210a8d4b0b76d77b',\n  inside: '<html style=\"padding: 1in; font-size: 50;\">Inside HTML for {{name}}</html>',\n  outside: '<html style=\"padding: 1in; font-size: 20;\">Outside HTML for {{name}}</html>',\n  merge_variables: {\n    name: 'Harry'\n  },\n  use_type: 'marketing'\n  qr_code : {\n    position: 'relative',\n    redirect_url: 'https://www.lob.com',\n    width: '2.5',\n    bottom: '2.5',\n    left: '2.5',\n    pages: 'inside'\n  },\n  fsc: true,\n  print_speed: 'core'\n}, function (err, res) {\n  console.log(err, res);\n});\n"
        label: NODE
      - lang: Ruby
        source: "selfMailerCreate = SelfMailerEditable.new({\n  description: \"Demo Self Mailer job\",\n  from: \"adr_210a8d4b0b76d77b\",\n  inside: \"<html style='padding: 1in; font-size: 50;'>Inside HTML for {{name}}</html>\",\n  outside: \"<html style='padding: 1in; font-size: 20;'>Outside HTML for {{name}}</html>\",\n  to: AddressEditable.new({\n    name: \"Harry Zhang\",\n    address_line1: \"210 King St\",\n    address_line2: \"# 6100\",\n    address_city: \"San Francisco\",\n    address_state: \"CA\",\n    address_zip: \"94107\",\n  }),\n  merge_variables: {\n    name: \"Harry\"\n  },\n  use_type: 'marketing'\n  qr_code : {\n    position: 'relative',\n    redirect_url: 'https://www.lob.com',\n    width: '2.5',\n    bottom: '2.5',\n    left: '2.5',\n    pages: 'inside'\n  },\n  fsc: true,\n  print_speed: \"core\"\n});\n\nselfMailerApi = SelfMailersApi.new(config)\n\nbegin\n  createdSelfMailer = selfMailerApi.create(selfMailerCreate)\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "self_mailer_editable = SelfMailerEditable(\n  description = \"Demo Self Mailer job\",\n  _from = \"adr_210a8d4b0b76d77b\",\n  inside = \"<html style='padding: 1in; font-size: 50;'>Inside HTML for {{name}}</html>\",\n  outside = \"<html style='padding: 1in; font-size: 20;'>Outside HTML for {{name}}</html>\",\n  to = AddressEditable(\n    name = \"Harry Zhang\",\n    address_line1 = \"210 King St\",\n    address_line2 = \"# 6100\",\n    address_city = \"San Francisco\",\n    address_state = \"CA\",\n    address_zip = \"94107\",\n  ),\n  merge_variables = MergeVariables(\n    name = \"Harry\",\n  ),\n  use_type = \"marketing\"\n  qr_code = {\n    position: \"relative\",\n    redirect_url: \"https://www.lob.com\",\n    width: \"2.5\",\n    bottom: \"2.5\",\n    left: \"2.5\",\n    pages: \"inside\"\n  },\n  fsc = true,\n  print_speed = \"core\"\n)\n\nwith ApiClient(configuration) as api_client:\n  api = SelfMailersApi(api_client)\n\ntry:\n  created_self_mailer = api.create(self_mailer_editable)\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$to = new OpenAPI\\Client\\Model\\AddressEditable(\n  array(\n    \"name\"     => \"Harry Zhang\",\n    \"address_line1\"     => \"210 King St\",\n    \"address_line2\"     => \"# 6100\",\n    \"address_city\"     => \"San Francisco\",\n    \"address_state\"     => \"CA\",\n    \"address_zip\"     => \"94107\",\n  )\n);\n\n$merge_variables = new stdClass;\n$merge_variables->name = \"Harry\";\n\n$use_type = \"marketing\";\n$fsc = true;\n$print_speed = 'core';\n\n$qr_code = new OpenAPI\\Client\\Model\\QRCode(\n  array(\n    \"position\" => \"relative\",\n    \"redirect_url\" => \"https://www.lob.com\",\n    \"width\" => \"2\",\n    \"bottom\" => \"2\",\n    \"left\" => \"2\",\n    \"pages\" => \"inside,outside\"\n  )\n);\n\n$apiInstance = new OpenAPI\\Client\\Api\\SelfMailersApi($config, new GuzzleHttp\\Client());\n$self_mailer_editable = new OpenAPI\\Client\\Model\\SelfMailerEditable(\n  array(\n    \"description\"     => \"Demo Self Mailer job\",\n    \"from\"     => \"adr_210a8d4b0b76d77b\",\n    \"inside\"     => \"<html style='padding: 1in; font-size: 50;'>Inside HTML for {{name}}</html>\",\n    \"outside\"     => \"<html style='padding: 1in; font-size: 20;'>Outside HTML for {{name}}</html>\",\n    \"to\"     => $to,\n    \"merge_variables\"     => $merge_variables,\n    \"use_type\"    => $use_type,\n    \"qr_code\"   => $qr_code,\n    \"fsc\"  => $fsc,\n    \"print_speed\" => \"core\"\n  )\n);\n\ntry {\n    $result = $apiInstance->create($self_mailer_editable);\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "Map<String, String> merge_variables = new HashMap<String, String>();\nmerge_variables.put(\"name\", \"Harry\");\n\nSelfMailersApi apiInstance = new SelfMailersApi(config);\n\nAddressEditable to = new AddressEditable();\nto.setName(\"Harry Zhang\");\nto.setAddressLine1(\"210 King St\");\nto.setAddressLine2(\"# 6100\");\nto.setAddressCity(\"San Francisco\");\nto.setAddressState(\"CA\");\nto.setAddressZip(\"94107\");\n\nQRCode qrCode = new QRCode();\nqrCode.setPosition(\"relative\");\nqrCode.setRedirectUrl(\"https://www.lob.com\");\nqrCode.setWidth(\"2\");\nqrCode.setLeft(\"2\");\nqrCode.setBottom(\"2\");\nqrCode.setPages(\"outside\");\n\ntry {\n  SelfMailerEditable selfMailerEditable = new SelfMailerEditable();\n  selfMailerEditable.setDescription(\"Demo Self Mailer job\");\n  selfMailerEditable.setFrom(\"adr_210a8d4b0b76d77b\");\n  selfMailerEditable.setInside(\"<html style='padding: 1in; font-size: 50;'>Inside HTML for {{name}}</html>\");\n  selfMailerEditable.setOutside(\"<html style='padding: 1in; font-size: 20;'>Outside HTML for {{name}}</html>\");\n  selfMailerEditable.setTo(to);\n  selfMailerEditable.setMergeVariables(merge_variables);\n  selfMailerEditable.setUseType(\"marketing\");\n  selfMailerEditable.setQRCode(qrCode);\n  selfMailerEditable.setFsc(true);\n  selfMailerEditable.setPrintSpeed(\"core\");\n\n\n  SelfMailer result = apiInstance.create(selfMailerEditable, null);\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: "Lob.SelfMailer.create(%{\n  description: \"Demo Self Mailer job\",\n  to: %{\n    name: \"Harry Zhang\",\n    address_line1: \"210 King St\",\n    address_city: \"San Francisco\",\n    address_state: \"CA\",\n    address_zip: \"94107\"\n  },\n  from: \"adr_210a8d4b0b76d77b\",\n  inside: \"<html style='padding: 1in; font-size: 50;'>Inside HTML for {{name}}</html>\",\n  outside: \"<html style='padding: 1in; font-size: 20;'>Outside HTML for {{name}}</html>\",\n  merge_variables: %{\n    name: \"Harry\"\n  },\n  use_type: \"marketing\"\n  qr_code: %{\n    position: 'relative',\n    redirect_url: 'https://www.lob.com',\n    width: '2',\n    bottom: '2',\n    left: '2',\n    pages: 'inside,outside'\n  },\n  fsc: true,\n  print_speed: 'core'\n})\n"
        label: ELIXIR
      - lang: CSharp
        source: "Dictionary<string, string> mergeVariables = new Dictionary<string, string>();\nmergeVariables.Add(\"name\", \"Harry\");\n\nSelfMailersApi api = new SelfMailersApi(config);\n\nAddressEditable to = new AddressEditable(\n  \"210 King St\",  // addressLine1\n  \"# 6100\",  // addressLine2\n  \"San Francisco\",  // addressCity\n  \"CA\",  // addressState\n  \"94107\",  // addressZip\n  default(CountryExtended),  // addressCounty\n  null,  // description\n  \"Harry Zhang\" // name\n);\n\nQRCode qrCode = new QRCode(\n  \"relative\",  //position,\n  \"https://www.lob.com\", //redirect_url\n  \"2\", //width\n  \"2\", //left\n  \"2\", //bottom\n  \"inside\", //pages\n);\n\nFsc fsc = new Fsc(true);\nPrintSpeed printSpeed = new PrintSpeed(\"core\");\n\nSelfMailerEditable selfMailerEditable = new SelfMailerEditable(\n  to.ToJson(),  // to\n  \"adr_249af768103d2810\",  // from\n  default(SelfMailerSize),  // size\n  \"Demo Self Mailer Job\",  // description\n  default(Dictionary<string, string>),  // metadata\n  default(MailType),  // mailType\n  mergeVariables,  // mergeVariables\n  default(DateTime),  // sendDate\n  \"<html style='padding: 1in; font-size: 50;'>Inside HTML for {{name}}</html>\",  // inside\n  \"<html style='padding: 1in; font-size: 20;'>Outside HTML for {{name}}</html>\", // outside\n  \"marketing\", // use_type \n  qrCode,\n  fsc,\n  \"core\" // print_speed\n);\n\ntry {\n  SelfMailer result = api.create(selfMailerEditable, null);\n} catch (ApiException e) {\n  Console.WriteLine(e.ToString());\n}\n"
        label: CSHARP
      - lang: Go
        source: "var context = context.Background()\ncontext = context.WithValue(suite.ctx, lob.ContextBasicAuth, lob.BasicAuth{UserName: os.Getenv(\"<YOUR_API_KEY>\")})\n\nvar apiClient = *lob.NewAPIClient(configuration)\n\nvar to = *lob.NewAddressEditable()\nto.SetAddressLine1(\"210 King St\")\nto.SetAddressLine2(\"# 6100\")\nto.SetAddressCity(\"San Francisco\")\nto.SetAddressState(\"CA\")\nto.SetAddressZip(\"94107\")\nto.SetAddressCountry(lob.COUNTRYEXTENDED_US)\nto.SetDescription(\"\")\nto.SetName(\"Harry Zhang\")\n\nvar selfMailerCreate = *lob.NewSelfMailerEditable()\nselfMailerCreate.SetDescription(\"Demo Self Mailer job\")\nselfMailerCreate.SetFrom(\"adr_210a8d4b0b76d77b\")\nselfMailerCreate.SetInside(\"<html style='padding: 1in; font-size: 50;'>Inside HTML for {{name}}</html>\")\nselfMailerCreate.SetOutside(\"<html style='padding: 1in; font-size: 20;'>Outside HTML for {{name}}</html>\")\nselfMailerCreate.SetTo(to)\nselfMailerCreate.SetFsc(true)\nselfMailerCreate.SetPrintSpeed(\"core\")\n\n\ncreatedselfMailer, _, err := apiClient.SelfMailersApi.Create(context).SelfMailerEditable(selfMailerCreate).Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
components:
  schemas:
    sfm_id:
      type: string
      description: Unique identifier prefixed with `sfm_`.
      pattern: ^sfm_[a-zA-Z0-9]+$
    thumbnail:
      type: object
      properties:
        small:
          $ref: '#/components/schemas/signed_link'
        medium:
          $ref: '#/components/schemas/signed_link'
        large:
          $ref: '#/components/schemas/signed_link'
    mail_type:
      type: string
      enum:
      - usps_first_class
      - usps_standard
      description: 'A string designating the mail postage type:

        * `usps_first_class` - (default)

        * `usps_standard` - a <a href="https://lob.com/pricing/print-mail#compare" target="_blank">cheaper option</a> which is

        less predictable and takes longer to deliver. `usps_standard` cannot be used with `4x6`

        postcards or for any postcards sent outside of the United States.

        '
      default: usps_first_class
    metadata:
      type: object
      additionalProperties:
        type: string
      description: 'Use metadata to store custom information for tagging and labeling back to your internal systems. Must be an object with up to 20 key-value pairs. Keys must be at most 40 characters and values must be at most 500 characters. Neither can contain the characters `"` and `\`. i.e. ''{"customer_id" : "NEWYORK2015"}'' Nested objects are not supported.  See [Metadata](#section/Metadata) for more information.'
      maxLength: 500
      pattern: '[^"\\]{0,500}'
    inline_address_intl:
      allOf:
      - $ref: '#/components/schemas/address_editable_intl'
      - type: object
        required:
        - address_line1
        - address_country
      - type: object
        oneOf:
        - required:
          - address_city
          - address_state
        - required:
          - address_zip
    print_speed:
      type:
      - string
      - 'null'
      enum:
      - core
      description: 'A string designating the mail speed type:

        * `core` - 2 production business days

        '
      default: core
    failure_reason_error:
      type: object
      description: Failure error details
      properties:
        url:
          type:
          - string
          - 'null'
          description: Failed URL of asset
        host:
          type:
          - string
          - 'null'
          description: URL host
        path:
          type:
          - string
          - 'null'
          description: URL path
        protocol:
          type:
          - string
          - 'null'
          description: Network protocol
        remediation:
          type:
          - string
          - 'null'
          description: Instructions on how to resolve the error
        error_type:
          type:
          - string
          - 'null'
          description: HTTP response status code message or service defined error
        status_code:
          type:
          - number
          - 'null'
          description: HTTP response status codes if the error is asset related
    address_editable_us:
      allOf:
      - $ref: '#/components/schemas/address_fields_us'
      - type: object
        anyOf:
        - title: address obj with `name` defined
          required:
          - name
        - title: address obj with `company` defined
          required:
          - company
        properties:
          description:
            $ref: '#/components/schemas/resource_description'
          name:
            type:
            - string
            - 'null'
            description: 'Either `name` or `company` is required, you may also add both. Must be no longer than 40 characters. If both `name` and `company` are provided, they will be printed on two separate lines above the rest of the address.

              '
            maxLength: 40
          company:
            $ref: '#/components/schemas/company'
          phone:
            type:
            - string
            - 'null'
            description: Must be no longer than 40 characters.
            maxLength: 40
          email:
            type:
            - string
            - 'null'
            description: Must be no longer than 100 characters.
            maxLength: 100
          address_country:
            type: string
            enum:
            - US
            default: US
          metadata:
            $ref: '#/components/schemas/metadata'
    adr_id:
      type: string
      description: Unique identifier prefixed with `adr_`.
      pattern: ^adr_[a-zA-Z0-9]+$
    tmpl_id:
      type: string
      description: Unique identifier prefixed with `tmpl_`. ID of a saved [HTML template](#section/HTML-Templates).
      pattern: ^tmpl_[a-zA-Z0-9]+$
    country_extended:
      type: string
      description: Must be a 2 letter country short-name code (ISO 3166). Does not accept `US`, `AS`, `PR`, `FM`, `GU`, `MH`, `MP`, `PW`, or `VI`. For these addresses, please use the US verification API. Also does not accept `PS`, which is not currently supported.
      enum:
      - AD
      - AE
      - AF
      - AG
      - AI
      - AL
      - AN
      - AO
      - AQ
      - AR
      - AT
      - AU
      - AW
      - AZ
      - BA
      - BB
      - BD
      - BE
      - BF
      - BG
      - BH
      - BI
      - BJ
      - BM
      - BN
      - BO
      - BQ
      - BR
      - BS
      - BT
      - BW
      - BY
      - BZ
      - CA
      - CD
      - CG
      - CH
      - CI
      - CK
      - CL
      - CM
      - CN
      - CO
      - CR
      - CS
      - CU
      - CV
      - CW
      - CY
      - CZ
      - DE
      - DJ
      - DK
      - DM
      - DO
      - DZ
      - EC
      - EE
      - EG
      - EH
      - ER
      - ES
      - ET
      - FI
      - FJ
      - FK
      - FO
      - FR
      - GA
      - GB
      - GD
      - GE
      - GH
      - GI
      - GL
      - GM
      - GN
      - GQ
      - GR
      - GS
      - GT
      - GW
      - GY
      - HK
      - HN
      - HR
      - HT
      - HU
      - ID
      - IE
      - IL
      - IN
      - IO
      - IQ
      - IR
      - IS
      - IT
      - JM
      - JO
      - JP
      - KE
      - KG
      - KH
      - KI
      - K

# --- truncated at 32 KB (104 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/lobcom/refs/heads/main/openapi/lobcom-self-mailers-api-openapi.yml