Lob.com Postcards API

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

Operations 4

GET /postcards/{psc_id} Retrieve #
DELETE /postcards/{psc_id} Cancel #
GET /postcards List #
POST /postcards Create #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/lobcom-postcards-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no email required.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

lobcom-postcards-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Lob Postcards 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: Postcards
  description: 'The postcards endpoint allows you to easily print and mail postcards. The API provides endpoints for creating postcards,

    retrieving individual postcards, canceling postcards, and retrieving a list of postcards.

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

    '
paths:
  /postcards/{psc_id}:
    parameters:
    - in: path
      name: psc_id
      description: id of the postcard
      required: true
      schema:
        $ref: '#/components/schemas/psc_id'
    get:
      operationId: postcard_retrieve
      summary: Retrieve
      description: Retrieves the details of an existing postcard. You need only supply the unique customer identifier that was returned upon postcard creation.
      tags:
      - Postcards
      responses:
        '200':
          description: Returns a postcard object
          content:
            $ref: '#/components/mediaTypes/postcard'
        default:
          $ref: '#/components/responses/mailpiece_error'
      x-codeSamples:
      - lang: Shell
        source: "curl https://api.lob.com/v1/postcards/psc_5c002b86ce47537a \\\n  -u REDACTED_LOB_KEY:\n"
        label: CURL
      - lang: Typescript
        source: "try {\n  const postcard = await new PostCardsApi(config).get('psc_xxxx');\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: "Lob.postcards.retrieve('psc_5c002b86ce47537a', function (err, res) {\n  console.log(err, res);\n});\n"
        label: NODE
      - lang: Ruby
        source: "letterApi = LettersApi.new(config)\n\nbegin\n  retrievedLetter = letterApi.get(\"ltr_4868c3b754655f90\")\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = PostcardsApi(api_client)\n\ntry:\n  postcard = api.get(\"psc_5c002b86ce47537a\")\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\PostcardsApi($config, new GuzzleHttp\\Client());\n\ntry {\n    $result = $apiInstance->get(\"psc_5c002b86ce47537a\");\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "PostcardsApi apiInstance = new PostcardsApi(config);\n\ntry {\n  Postcard response = apiInstance.get(\"psc_5c002b86ce47537a\");\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'Lob.Postcard.find("psc_5c002b86ce47537a")

          '
        label: ELIXIR
      - lang: CSharp
        source: "PostcardsApi api = new PostcardsApi(config);\n\ntry {\n  Postcard response = api.get(\"psc_5c002b86ce47537a\");\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\nfetchedPostcard, _, err := apiClient.PostcardsApi.Get(context,\"psc_5c002b86ce47537a\").Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
    delete:
      operationId: postcard_delete
      summary: Cancel
      description: Completely removes a postcard from production. This can only be done if the postcard has a `send_date` and the `send_date` has not yet passed. If the postcard is successfully canceled, you will not be charged for it. Read more on [cancellation windows](#section/Cancellation-Windows) and [scheduling](#section/Scheduled-Mailings). Scheduling and cancellation is a premium feature. Upgrade to the appropriate <a href="https://dashboard.lob.com/#/settings/editions" target="_blank">Print & Mail Edition</a> to gain access.
      tags:
      - Postcards
      responses:
        '200':
          $ref: '#/components/responses/postcard_deleted'
        default:
          $ref: '#/components/responses/mailpiece_error'
      x-codeSamples:
      - lang: Shell
        source: "curl -X DELETE https://api.lob.com/v1/postcards/psc_5c002b86ce47537a \\\n  -u REDACTED_LOB_KEY:\n"
        label: CURL
      - lang: Typescript
        source: "try {\n  const deletePostcard = await new PostcardsApi(config).cancel('psc_xxxx');\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: "Lob.postcards.cancel('psc_5c002b86ce47537a', function (err, res) {\n  console.log(err, res);\n});\n"
        label: NODE
      - lang: Ruby
        source: "postcardApi = PostcardsApi.new(config)\n\nbegin\n  deletedPostcard = postcardApi.cancel(\"psc_4868c3b754655f90\")\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = PostcardsApi(api_client)\n\ntry:\n  deleted_resource = api.cancel(\"psc_5c002b86ce47537a\")\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\PostcardsApi($config, new GuzzleHttp\\Client());\n\ntry {\n    $result = $apiInstance->cancel(\"psc_5c002b86ce47537a\");\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "PostcardsApi apiInstance = new PostcardsApi(config);\n\ntry {\n    PostcardDeletion response = apiInstance.cancel(\"psc_5c002b86ce47537a\");\n} catch (ApiException e) {\n    e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'Lob.Postcard.destroy("psc_5c002b86ce47537a")

          '
        label: ELIXIR
      - lang: CSharp
        source: "PostcardsApi api = new PostcardsApi(config);\n\ntry {\n  PostcardDeletion response = api.cancel(\"psc_5c002b86ce47537a\");\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\ndeletedPostcard, _, err := apiClient.PostcardsApi.Cancel(context, \"psc_5c002b86ce47537a\").Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
  /postcards:
    get:
      operationId: postcards_list
      summary: List
      description: Returns a list of your postcards. The addresses are returned sorted by creation date, with the most recently created addresses appearing first.
      tags:
      - Postcards
      parameters:
      - $ref: '#/components/parameters/limit'
      - $ref: '#/components/parameters/before_after'
      - $ref: '#/components/parameters/include'
      - $ref: '#/components/parameters/date_created'
      - $ref: '#/components/parameters/metadata'
      - $ref: '#/components/parameters/campaign_id'
      - $ref: '#/components/parameters/status'
      - in: query
        name: size
        description: Specifies the size of the postcard. Only `4x6` postcards can be sent to international destinations.
        schema:
          type: array
          items:
            $ref: '#/components/schemas/postcard_size'
      - $ref: '#/components/parameters/scheduled'
      - $ref: '#/components/parameters/send_date'
      - $ref: '#/components/parameters/mail_type'
      - $ref: '#/components/parameters/sort_by'
      responses:
        '200':
          $ref: '#/components/responses/all_postcards'
        default:
          $ref: '#/components/responses/mailpiece_error'
      x-codeSamples:
      - lang: Shell
        source: "curl -X GET \"https://api.lob.com/v1/postcards?limit=2\" \\\n  -u REDACTED_LOB_KEY:\n"
        label: CURL
      - lang: typescript
        source: "try {\n  const postcards = await new PostcardsApi(config).list(2);\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: "Lob.postcards.list({limit: 2}, function (err, res) {\n  console.log(err, res);\n});\n"
        label: NODE
      - lang: Ruby
        source: "postcardsApi = PostcardsApi.new(config)\n\nbegin\n  postcards = postcardsApi.list({ limit: 2 })\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = PostcardsApi(api_client)\n\ntry:\n  postcards = api.list(limit=2)\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\PostcardsApi($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: "PostcardsApi apiInstance = new PostcardsApi(config);\n\ntry {\n  PostcardList 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.Postcard.list(%{limit: 2})

          '
        label: ELIXIR
      - lang: CSharp
        source: "PostcardsApi api = new PostcardsApi(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);\nList<PostcardSize> sizeArray = new List<PostcardSize>();\nsizeArray.Add(PostcardSize._4x6);\n\ntry {\n  PostcardList response = api.list(\n    2, // limit\n    null, // before\n    null, // after\n    includeList, // include\n    dateCreated, // dateCreated\n    metadata, // metadata\n    sizeArray, // 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)\nPostcardList = apiClient.PostcardsApi.List(context).Execute()\nif err != nil {\n    return err\n}\n"
        label: GO
    post:
      operationId: postcard_create
      summary: Create
      description: Creates a new postcard given information
      tags:
      - Postcards
      parameters:
      - $ref: '#/components/parameters/idem-header'
      - $ref: '#/components/parameters/idem-query'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/postcard_editable'
            example:
              description: demo
              to:
                description: Harry - Office
                name: Harry Zhang
                company: Lob
                email: harry@lob.com
                phone: '5555555555'
                address_line1: 210 King St
                address_line2: '# 6100'
                address_city: San Francisco
                address_state: CA
                address_zip: '94107'
                address_country: US
              from:
                description: Harry - Office
                name: Harry Zhang
                company: Lob
                email: harry@lob.com
                phone: '5555555555'
                address_line1: 210 King St
                address_line2: '# 6100'
                address_city: San Francisco
                address_state: CA
                address_zip: '94107'
                address_country: US
              front: tmpl_a1234dddg
              back: tmpl_a1234dddg
              size: 6x9
              mail_type: usps_first_class
              merge_variables:
                name: Harry
              metadata:
                spiffy: 'true'
              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: front,back
              fsc: true
              print_speed: core
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/postcard_editable'
            example:
              description: demo
              to:
                description: Harry - Office
                name: Harry Zhang
                company: Lob
                email: harry@lob.com
                phone: '5555555555'
                address_line1: 210 King St
                address_line2: '# 6100'
                address_city: San Francisco
                address_state: CA
                address_zip: '94107'
                address_country: US
              from:
                description: Harry - Office
                name: Harry Zhang
                company: Lob
                email: harry@lob.com
                phone: '5555555555'
                address_line1: 210 King St
                address_line2: '# 6100'
                address_city: San Francisco
                address_state: CA
                address_zip: '94107'
                address_country: US
              front: tmpl_c94e83ca2cd5121
              back: tmpl_c94e83ca2cd5121
              size: 6x9
              mail_type: usps_first_class
              merge_variables:
                name: Harry
              metadata:
                spiffy: 'true'
              send_date: '2017-11-01T00:00:00.000Z'
              use_type: marketing
              qr_code:
                position: relative
                redirect_url: https://www.lob.com
                width: '2.5'
                bottom: '2.5'
                right: '2.5'
                pages: back
              fsc: true
              print_speed: core
            encoding:
              to:
                style: deepObject
                explode: true
              from:
                style: deepObject
                explode: true
              merge_variables:
                style: deepObject
                explode: true
              metadata:
                style: deepObject
                explode: true
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/postcard_editable'
            example:
              description: demo
              to:
                description: Harry - Office
                name: Harry Zhang
                company: Lob
                email: harry@lob.com
                phone: '5555555555'
                address_line1: 210 King St
                address_line2: '# 6100'
                address_city: San Francisco
                address_state: CA
                address_zip: '94107'
                address_country: US
              from:
                description: Harry - Office
                name: Harry Zhang
                company: Lob
                email: harry@lob.com
                phone: '5555555555'
                address_line1: 210 King St
                address_line2: '# 6100'
                address_city: San Francisco
                address_state: CA
                address_zip: '94107'
                address_country: US
              front: tmpl_a1234dddg
              back: tmpl_a1234dddg
              size: 6x9
              mail_type: usps_first_class
              merge_variables:
                name: Harry
              metadata:
                spiffy: 'true'
              send_date: '2017-11-01T00:00:00.000Z'
              use_type: marketing
              qr_code:
                position: relative
                redirect_url: https://www.lob.com
                width: '2.5'
                bottom: '2.5'
                left: '2.5'
                pages: front
              fsc: true
              print_speed: core
      responses:
        '200':
          $ref: '#/components/responses/post_postcard'
        default:
          $ref: '#/components/responses/mailpiece_error'
      x-codeSamples:
      - lang: Shell
        source: "curl https://api.lob.com/v1/postcards \\\n  -u REDACTED_LOB_KEY: \\\n  -d 'description=Demo Postcard job' \\\n  -d 'to[name]=Harry Zhang' \\\n  -d 'to[address_line1]=210 King St' \\\n  -d 'to[address_line2]=# 6100' \\\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  --data-urlencode 'front=<html style=\"padding: 1in; font-size: 50;\">Front HTML for {{name}}</html>' \\\n  --data-urlencode 'back=<html style=\"padding: 1in; font-size: 20;\">Back HTML for {{name}}</html>' \\\n  -d 'merge_variables[name]=Harry' \\\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]=front,back' \\\n  -d 'fsc=true' \\\n  -d 'print_speed=core'\n"
        label: CURL
      - lang: Typescript
        source: "const postcardCreate = new PostcardEditable({\nto: new 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}),\nfrom: 'adr_xxxx',\nfront:\n'https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf',\nback: 'https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf',\nuse_type: 'marketing',\nqr_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: 'front'\n},\nfsc: true,\nprint_speed: 'core'\n});\n\ntry {\n  const myPostcard = await new PostcardsApi(config).create(postcardCreate);\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: "Lob.postcards.create({\n  description: 'Demo Postcard job',\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_210a8d4b0b76d77b',\n  front: '<html style=\"padding: 1in; font-size: 50;\">Front HTML for {{name}}</html>',\n  back: '<html style=\"padding: 1in; font-size: 20;\">Back 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: 'back'\n  },\n  fsc: true,\n  print_speed: 'core'\n}, function (err, res) {\n  console.log(err, res);\n});\n"
        label: NODE
      - lang: Ruby
        source: "postcardCreate = PostcardEditable.new({\n  description: \"Demo Postcard job\",\n  from: \"adr_210a8d4b0b76d77b\",\n  front: \"<html style='padding: 1in; font-size: 50;'>Front HTML for {{name}}</html>\",\n  back: \"<html style='padding: 1in; font-size: 20;'>Back 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  fsc: true,\n  print_speed: \"core\"\n});\n\npostcardApi = PostcardsApi.new(config)\n\nbegin\n  createdPostcard = postcardApi.create(postcardCreate)\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "postcard_editable = PostcardEditable(\n  description = \"Demo Postcard job\",\n  _from = \"adr_210a8d4b0b76d77b\",\n  front = \"<html style='padding: 1in; font-size: 50;'>Front HTML for {{name}}</html>\",\n  back = \"<html style='padding: 1in; font-size: 20;'>Back 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\" : \"front\"\n  },\n  fsc = true,\n  print_speed = \"core\"\n)\n\nwith ApiClient(configuration) as api_client:\n  api = PostcardsApi(api_client)\n\ntry:\n  created_postcard = api.create(postcard_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$use_type = \"marketing\";\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\" => \"front,back\"\n  )\n);\n\n$fsc = true;\n$print_speed = 'core';\n\n$apiInstance = new OpenAPI\\Client\\Api\\PostcardsApi($config, new GuzzleHttp\\Client());\n$postcard_editable = new OpenAPI\\Client\\Model\\PostcardEditable(\n  array(\n    \"description\"     => \"Demo Postcard job\",\n    \"from\"     => \"adr_210a8d4b0b76d77b\",\n    \"front\"     => \"<html style='padding: 1in; font-size: 50;'>Front HTML for {{name}}</html>\",\n    \"back\"     => \"<html style='padding: 1in; font-size: 20;'>Back 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($postcard_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\nPostcardsApi apiInstance = new PostcardsApi(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(\"back\");\n\ntry {\n  PostcardEditable postcardEditable = new PostcardEditable();\n  postcardEditable.setDescription(\"Demo Postcard job\");\n  postcardEditable.setFrom(\"adr_210a8d4b0b76d77b\");\n  postcardEditable.setFront(\"<html style='padding: 1in; font-size: 50;'>Front HTML for {{name}}</html>\");\n  postcardEditable.setBack(\"<html style='padding: 1in; font-size: 20;'>Back HTML for {{name}}</html>\");\n  postcardEditable.setTo(to);\n  postcardEditable.setMergeVariables(merge_variables);\n  postcardEditable.setUseType(\"operational\");\n  postcardEditable.setQRCode(qrCode);\n  postcardEditable.setFsc(true);\n  postcardEditable.setPrintSpeed(\"core\");\n\n  Postcard result = apiInstance.create(postcardEditable, null);\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: "Lob.Postcard.create(%{\n  description: 'Demo Postcard job',\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_210a8d4b0b76d77b',\n  front: '<html style=\"padding: 1in; font-size: 50;\">Front HTML for {{name}}</html>',\n  back: '<html style=\"padding: 1in; font-size: 20;\">Back 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: 'front,back'\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\nPostcardsApi api = new PostcardsApi(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  CountryExtended.US,  // addressCounty\n  null,  // description\n  \"Harry Zhang\" // name\n);\n\nUseType usetype = new UseType('marketing');\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  \"front\", //pages\n);\n\nFsc fsc = new Fsc(true);\nPrintSpeed printSpeed = new PrintSpeed(\"core\");\n\nPostcardEditable postcardEditable = new PostcardEditable(\n  to.ToJson(),  // to\n  \"adr_249af768103d2810\",  // from\n  default(PostcardSize),  // size\n  \"Demo Postcard Job\",  // description\n  null,  // metadata\n  default(MailType),  // mailType\n  mergeVariables,  // mergeVariables\n  default(DateTime),  // sendDate\n  \"<html style='padding: 1in; font-size: 20;'>Back HTML for {{name}}</html>\",  // front\n  \"<html style='padding: 1in; font-size: 20;'>Back HTML for {{name}}</html>\", // back\n  usetype,\n  qrCode,\n  fsc,\n  \"core\"  // printSpeed\n);\n\ntry {\n  Postcard result = api.create(postcardEditable, 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 postcardCreate = *lob.NewPostcardEditable()\npostcardCreate.SetDescription(\"Demo Postcard job\")\npostcardCreate.SetFrom(\"adr_210a8d4b0b76d77b\")\npostcardCreate.SetFront(\"<html style='padding: 1in; font-size: 50;'>Front HTML for {{name}}</html>\")\npostcardCreate.SetBack(\"<html style='padding: 1in; font-size: 20;'>Back HTML for {{name}}</html>\")\npostcardCreate.SetTo(to)\npostcardCreate.SetFsc(true)\npostcardCreate.SetPrintSpeed(\"core\")\n\n\ncreatedpostcard, _, err := apiClient.PostcardsApi.Create(context).PostcardEditable(postcardCreate).Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
components:
  schemas:
    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]+$
    error:
      type: object
      description: Lob uses RESTful HTTP response codes to indicate success or failure of an API request. In general, 2xx indicates success, 4xx indicate an input error, and 5xx indicates an error on Lob's end.
      required:
      - error
      properties:
        error:
          type: object
          required:
          - message
          - status_code
          - code
          properties:
            message:
              type: string
              description: A human-readable message with more details about the error
              example: Rate limit exceeded. Please wait 5 seconds and try your request again.
            status_code:
              $ref: '#/components/schemas/failure_status_code'
            code:
              type: string
              enum:
              - bad_request
              - conflict
              - feature_limit_reached
              - internal_server_error
              - invalid
              - not_deletable
              - not_found
              - request_timeout
              - service_unavailable
              - unrecognized_endpoint
              - unsupported_lob_version
              - address_length_exceeds_limit
              - bank_account_already_verified
              - bank_error
              - billing_address_required
              - custom_envelope_inventory_depleted
              - deleted_bank_account
              - failed_deliverability_strictness
              - file_pages_below_min
              - file_pages_exceed_max
              - file_size_exceeds_limit
              - foreign_return_address
              - inconsistent_page_dimensions
              - invalid_bank_account
              - invalid_bank_account_verification
              - invalid_check_international
              - invalid_country_covid
              - invalid_file
              - invalid_file_dimensions
              - invalid_file_download_time
              - invalid_file_url
              - invalid_image_dpi
              - invalid_international_feature
              - invalid_perforation_return_envelope
              - invalid_template_html
              - mail_use_type_can_not_be_null
              - merge_variable_required
              - merge_variable_whitespace
              - payment_method_unverified
              - pdf_encrypted
              - special_characters_restricted
              - unembedded_fonts
              - email_required
              - invalid_api_key
              - publishable_key_not_allowed
              - rate_limit_exceeded
              - unauthorized
              - unauthorized_token
              description: 'A pre-defined string identifying an error. Error codes fall into three categories:


                **GENERIC**

                * `bad_request` - 422: an invalid request was made. See error message for details.

                * `conflict` - 409/422: this operation would leave data in a conflicted state.

                * `feature_limit_reached` - 403: the account has reached its resource limit and requires upgrading to add more.

                * `internal_server_error` - 500: an error has occured on Lob''s servers. Please try request again.

                * `invalid` - 422: an invalid request was made. See error message for details.

                * `not_deletable` - 422: an attempt was made to delete a resource, but the resource cannot be deleted.

                * `not_found` - 404: the requested resource was not found.

                * `request_timeout` - 408: the request took too long. Please try again.

                * `service_unavailable` - 503: the Lob servers are temporarily unavailable. Please try agian.

                * `unrecognized_endpoint` - 404: the requested endpoint doesn''t exist.

                * `unsupported_lob_version` - 422: an unsupported Lob API version was requested.


                **ADVANCED**

                * `address_length_exceeds_limit` - 422: the sum of to.address_line1 and to.address

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