Lob

Lob Templates API

These API endpoints allow you to create, retrieve, update and delete reusable HTML templates for use with the Print & Mail API. back to top

OpenAPI Specification

lob-templates-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Lob Templates API
  version: 1.20.2
  description: "Experience direct mail like never before, with unmatched personalization and scalability \x14 all in one intuitive platform."
  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: Templates
  description: 'These API endpoints allow you to create, retrieve, update and delete reusable HTML templates for use with the Print & Mail API.

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

    '
paths:
  /templates/{tmpl_id}/versions/{vrsn_id}:
    parameters:
    - in: path
      name: tmpl_id
      description: The ID of the template to which the version belongs.
      required: true
      schema:
        $ref: '#/components/schemas/tmpl_id'
    - in: path
      name: vrsn_id
      description: id of the template_version
      required: true
      schema:
        $ref: '#/components/schemas/vrsn_id'
    get:
      operationId: template_version_retrieve
      summary: Retrieve
      description: Retrieves the template version with the given template and version ids.
      tags:
      - Templates
      responses:
        '200':
          description: Returns the template version with the given template and version ids.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/template_version'
              example:
                id: vrsn_534e339882d2282
                description: Second Version
                html: <html>Second HTML for {{name}}</html>
                date_created: '2017-11-09T04:49:38.016Z'
                date_modified: '2017-11-09T04:49:38.016Z'
                object: version
        default:
          $ref: '#/components/responses/template_error'
      x-codeSamples:
      - lang: Shell
        source: "curl https://api.lob.com/v1/templates/tmpl_c94e83ca2cd5121/versions/vrsn_534e339882d2282 \\\n  -u test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc:\n"
        label: CURL
      - lang: Typescript
        source: "try {\n  const templateVersion = await new TemplateVersionsApi(config).get('tmpl_xxxx', 'vrsn_xxxx');\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: 'This feature is not currently supported by this library.

          '
        label: NODE
      - lang: Ruby
        source: "templateVersionApi = TemplateVersionsApi.new(config)\n\nbegin\n  retrievedTemplateVersion = templateVersionApi.get(\"tmpl_c94e83ca2cd5121\", \"vrsn_534e339882d2282\")\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = TemplateVersionsApi(api_client)\n\ntry:\n  template_version = api.get(\"tmpl_c94e83ca2cd5121\", \"vrsn_534e339882d2282\")\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\TemplateVersionsApi($config, new GuzzleHttp\\Client());\n\ntry {\n    $result = $apiInstance->get(\"tmpl_c94e83ca2cd5121\", \"vrsn_534e339882d2282\");\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "TemplateVersionsApi apiInstance = new TemplateVersionsApi(config);\n\ntry {\n  TemplateVersion response = apiInstance.get(\"vrsn_534e339882d2282\");\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'This feature is not currently supported by this library.

          '
        label: ELIXIR
      - lang: CSharp
        source: "TemplateVersionsApi api = new TemplateVersionsApi(config);\n\ntry {\n  TemplateVersion response = api.get(\"tmpl_c94e83ca2cd5121\", \"vrsn_534e339882d2282\");\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\nfetchedTemplateVersion, _, err := apiClient.TemplateVersionsApi.Get(context,\"tmpl_c94e83ca2cd5121\", \"vrsn_534e339882d2282\").Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
    post:
      operationId: template_version_update
      summary: Update
      description: Updates the template version with the given template and version ids.
      tags:
      - Templates
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/template_version_updatable'
            example:
              description: Some description
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/template_version_updatable'
            example:
              description: Some description
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/template_version_updatable'
            example:
              description: Some description
      responses:
        '200':
          $ref: '#/components/responses/post_template_version'
        default:
          $ref: '#/components/responses/template_error'
      x-codeSamples:
      - lang: Shell
        source: "curl https://api.lob.com/v1/templates/tmpl_c94e83ca2cd5121/versions/vrsn_534e339882d2282 \\\n  -u test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc: \\\n  -d \"description=Updated description\"\n"
        label: CURL
      - lang: Typescript
        source: "const TemplateVersions = new TemplateVersionsApi(config);\n\ntry {\n  const updateData = new TemplateVersionUpdatable({\n    description: 'updated template'\n  });\n  const updateTemplateVersion = await TemplateVersions.update('vrsn_xxxx', updateData);\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: 'This feature is not currently supported by this library.

          '
        label: NODE
      - lang: Ruby
        source: "templateVersionUpdatable = TemplateUpdate.new({\n  description: \"updated template version\",\n})\n\ntemplateVersionApi = TemplateVersionsApi.new(config)\n\nbegin\n  updatedTemplateVersion = templateVersionApi.update(\"tmpl_c94e83ca2cd5121\", \"vrsn_534e339882d2282\", templateVersionUpdatable)\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = TemplateVersionsApi(api_client)\n\nupdate_data = TemplateVersionUpdatable(\n  description = \"updated template\"\n)\n\ntry:\n  update_template_version = api.update(\"tmpl_c94e83ca2cd5121\", \"vrsn_534e339882d2282\", update_data)\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\TemplateVersionsApi($config, new GuzzleHttp\\Client());\n\n$templateVersionUpdate = new OpenAPI\\Client\\Model\\TemplateUpdate(array(\n    \"description\" =>  \"Updated template version\"\n));\n\ntry {\n    $result = $apiInstance->update(\"tmpl_c94e83ca2cd5121\", \"vrsn_534e339882d2282\", $templateVersionUpdate);\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: 'This feature is not currently supported by this library.

          '
        label: JAVA
      - lang: Elixir
        source: 'This feature is not currently supported by this library.

          '
        label: ELIXIR
      - lang: CSharp
        source: "TemplateVersionsApi api = new TemplateVersionsApi(config);\nTemplateVersionUpdatable update = new TemplateVersionUpdatable(\"update template\", EngineHtml.Handlebars);\n\ntry {\n  api.update(\"tmpl_c94e83ca2cd5121\", \"vrsn_534e339882d2282\", update);\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 templateWritable = *lob.NewTemplateWritable(\"<html>Updated HTML for Template 1/html>\")\nvar templateVersionWritable = *lob.NewTemplateVersionWritable(\"<html>Updated HTML for Template 1/html>\")\ncreatedTemplate, _, _ := apiClient.TemplatesApi.Create(context).TemplateWritable(templateWritable).Execute()\n\ncreatedTemplateVersion, _, err := apiClient.TemplateVersionsApi.Create(context, createdTemplate.Id).TemplateVersionWritable(templateVersionWritable).Execute()\ncreatedTemplateVersion.SetDescription(\"New Template Version\")\nresp, _, err := apiClient.TemplatesApi.Update(context, createdTemplate.Id, createdTemplateVersion.Id).TemplateVersionWritable(templateVersionWritable).Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
    delete:
      operationId: template_version_delete
      summary: Delete
      description: Permanently deletes a template version. A template's `published_version` can not be deleted.
      tags:
      - Templates
      responses:
        '200':
          $ref: '#/components/responses/template_version_deleted'
        default:
          $ref: '#/components/responses/template_error'
      x-codeSamples:
      - lang: Shell
        source: "curl -X DELETE https://api.lob.com/v1/templates/tmpl_4aa14648113e45b/versions/vrsn_534e339882d2282 \\\n  -u test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc:\n"
        label: CURL
      - lang: Typescript
        source: "try {\n  const deleteTemplateVersion = await new TemplateVersionsApi(config).delete(\"tmpl_xxxx\",\"vrsn_xxxx\");\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: 'This feature is not currently supported by this library.

          '
        label: NODE
      - lang: Ruby
        source: "templateVersionApi = TemplateVersionsApi.new(config)\n\nbegin\n  deletedTemplateVersion = templateVersionApi.delete(\"tmpl_4aa14648113e45b\", \"vrsn_534e339882d2282\")\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = TemplateVersionsApi(api_client)\n\ntry:\n  deleted_resource = api.delete(\"tmpl_4aa14648113e45b\", \"vrsn_534e339882d2282\")\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: 'This feature is not currently supported by this library.

          '
      - lang: Java
        source: 'This feature is not currently supported by this library.

          '
        label: JAVA
      - lang: Elixir
        source: 'This feature is not currently supported by this library.

          '
        label: ELIXIR
      - lang: CSharp
        source: "TemplateVersionsApi api = new TemplateVersionsApi(config);\n\ntry {\n  TemplateVersionDeletion response = api.delete(\"tmpl_xxx\", \"vrsn_xxx\");\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\ndeletedTemplateVersion, _, err := apiClient.TemplateVersionsApi.Delete(context, \"tmpl_4aa14648113e45b\", \"vrsn_534e339882d2282\").Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
  /templates/{tmpl_id}/versions:
    get:
      operationId: template_versions_list
      summary: List
      description: 'Returns a list of template versions for the given template ID. The template versions are sorted by creation date, with the most recently created appearing first.

        '
      tags:
      - Templates
      parameters:
      - in: path
        name: tmpl_id
        description: The ID of the template associated with the retrieved versions
        required: true
        schema:
          $ref: '#/components/schemas/tmpl_id'
      - $ref: '#/components/parameters/limit'
      - $ref: '#/components/parameters/before_after'
      - $ref: '#/components/parameters/include'
      - $ref: '#/components/parameters/date_created'
      responses:
        '200':
          $ref: '#/components/responses/all_template_versions'
        default:
          $ref: '#/components/responses/template_error'
      x-codeSamples:
      - lang: Shell
        source: "curl -X GET \"https://api.lob.com/v1/templates/tmpl_ea6e6a1abf01703/versions?limit=2\" \\\n  -u test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc:\n"
        label: CURL
      - lang: Typescript
        source: "try {\n  const templateVersions = await new TemplateVersionsApi(config).list(tmpl_xxxx);\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: 'This feature is not currently supported by this library.

          '
        label: NODE
      - lang: Ruby
        source: "templateVersionsApi = TemplateVersionsApi.new(config)\n\nbegin\n  templateVersions = templateVersionsApi.list(\"tmpl_dadaaf7b76c9f25\", { limit: 2 })\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = TemplateVersionsApi(api_client)\n\ntry:\n  template_versions = api.list(\"tmpl_dadaaf7b76c9f25\", limit=2)\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\TemplateVersionsApi($config, new GuzzleHttp\\Client());\n\ntry {\n    $result = $apiInstance->list(\n      tmpl_dadaaf7b76c9f25, // tmplId\n      2, // limit\n    );\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "TemplateVersionsApi apiInstance = new TemplateVersionsApi(config);\n\ntry {\n  List response = apiInstance.list(\n    \"tmpl_dadaaf7b76c9f25\", // tmplId\n    2, // limit\n    null, // before\n    null, // after\n    null, // include\n    null // dateCreated\n  );\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'This feature is not currently supported by this library.

          '
        label: ELIXIR
      - lang: CSharp
        source: "TemplateVersionsApi api = new TemplateVersionsApi(config);\n\nList<string> includeList = new List<string>();\nincludeList.Add(\"total_count\");\nDictionary<String, DateTime> dateCreated = new Dictionary<String, DateTime>();\nDateTime dateCreatedDate = DateTime.Today.AddMonths(-1);\ndateCreated.Add(\"lt\", dateCreatedDate);\n\ntry {\n  TemplateVersionList response = api.list(\n    \"tmpl_dadaaf7b76c9f25\", // tmplId\n    2, // limit\n    null, // before\n    null, // after\n    includeList, // include\n    dateCreated // dateCreated\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)\nTemplateVersionList = apiClient.TemplateVersionsApi.List(context, \"tmpl_4aa14648113e45b\").Execute()\nif err != nil {\n    return err\n}\n"
        label: GO
    post:
      operationId: create_template_version
      summary: Create
      description: Creates a new template version attached to the specified template.
      tags:
      - Templates
      parameters:
      - in: path
        name: tmpl_id
        description: The ID of the template the new version will be attached to
        required: true
        schema:
          $ref: '#/components/schemas/tmpl_id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/template_version_writable'
            example:
              description: Some Description
              html: <html>HTML for {{name}}</html>
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/template_version_writable'
            example:
              description: Some Description
              html: <html>HTML for {{name}}</html>
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/template_version_writable'
            example:
              description: Some Description
              html: <html>HTML for {{name}}</html>
      responses:
        '200':
          $ref: '#/components/responses/post_template_version'
        default:
          $ref: '#/components/responses/template_error'
      x-codeSamples:
      - lang: Shell
        source: "curl https://api.lob.com/v1/templates/tmpl_4aa14648113e45b/versions \\\n  -u test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc: \\\n  -d \"description=Second Version\" \\\n  --data-urlencode \"html=<html>Second HTML for {{name}}</html>\"\n"
        label: CURL
      - lang: Typescript
        source: "const templateVersionCreate = new TemplateVersionWritable({\n  description: 'Newer Template',\n  html: '<html>Updated HTML for {{name}}</html>'\n});\n\ntry {\n  const myTemplateVersion = await new TemplateVersionsApi(config).create('tmpl_xxxx', templateVersionCreate);\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: 'This feature is not currently supported by this library.

          '
        label: NODE
      - lang: Ruby
        source: "templateVersionCreate = TemplateVersionWritable.new({\n  description: \"Second Version\",\n  html: \"<html>Second HTML for {{name}}</html>\",\n});\n\ntemplateVersionApi = TemplateVersionsApi.new(config)\n\nbegin\n  createdTemplateVersion = templateVersionApi.create(\"tmpl_4aa14648113e45b\", templateVersionCreate)\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "template_version_writable = TemplateVersionWritable(\n  description = \"Second Version\",\n  html = \"<html>Second HTML for {{name}}</html>\",\n)\n\nwith ApiClient(configuration) as api_client:\n  api = TemplateVersionsApi(api_client)\n\ntry:\n  created_template_version = api.create(\"tmpl_4aa14648113e45b\", template_version_writable)\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\TemplateVersionsApi($config, new GuzzleHttp\\Client());\n$template_version_writable = new OpenAPI\\Client\\Model\\TemplateVersionWritable(\n  array(\n    \"description\"     => \"Second Version\",\n    \"html\"     => \"<html>Second HTML for {{name}}</html>\",\n  )\n);\n\ntry {\n    $result = $apiInstance->create(\"tmpl_4aa14648113e45b\", $template_version_writable);\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "TemplateVersionsApi apiInstance = new TemplateVersionsApi(config);\n\ntry {\n  TemplateVersionWritable  = new TemplateVersionWritable();\n  .set(\"Second Version\");\n  .set(\"<html>Second HTML for {{name}}</html>\");\n\n  TemplateVersion result = apiInstance.create();\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'This feature is not currently supported by this library.

          '
        label: ELIXIR
      - lang: CSharp
        source: "TemplateVersionsApi api = new TemplateVersionsApi(config);\n\nTemplateVersionWritable templateVersionWritable = new TemplateVersionWritable(\n  \"Second Version\",  // description\n  \"<html>Second HTML for {{name}}</html>\" // html\n);\n\ntry {\n  TemplateVersion result = api.create(\"tmpl_4aa14648113e45b\", templateVersionWritable);\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\n\nvar templateVersionCreate = *lob.NewTemplateVersionWritable()\ntemplateVersionCreate.SetDescription(\"Second Version\")\ntemplateVersionCreate.SetHtml(\"<html>Second HTML for {{name}}</html>\")\n\n\n\ncreatedtemplateVersion, _, err := apiClient.TemplateVersionsApi.Create(context, \"tmpl_4aa14648113e45b\").TemplateVersionWritable(templateVersionCreate).Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
  /templates/{tmpl_id}:
    parameters:
    - in: path
      name: tmpl_id
      description: id of the template
      required: true
      schema:
        $ref: '#/components/schemas/tmpl_id'
    get:
      operationId: template_retrieve
      summary: Retrieve
      description: Retrieves the details of an existing template. You need only supply the unique template identifier that was returned upon template creation.
      tags:
      - Templates
      responses:
        '200':
          description: Returns a template object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/template'
              example:
                id: tmpl_c94e83ca2cd5121
                description: Test Template
                versions:
                - id: vrsn_362184d96d9b0c9
                  suggest_json_editor: true
                  description: Test Template
                  engine: legacy
                  html: <html>HTML for {{name}}</html>
                  date_created: '2017-11-07T22:56:10.962Z'
                  date_modified: '2017-11-07T22:56:10.962Z'
                  object: version
                published_version:
                  id: vrsn_362184d96d9b0c9
                  suggest_json_editor: false
                  description: Test Template
                  engine: handlebars
                  html: <html>HTML for {{name}}</html>
                  date_created: '2017-11-07T22:56:10.962Z'
                  date_modified: '2017-11-07T22:56:10.962Z'
                  object: version
                metadata: {}
                date_created: '2017-11-07T22:56:10.962Z'
                date_modified: '2017-11-07T22:56:10.962Z'
                object: template
        default:
          $ref: '#/components/responses/template_error'
      x-codeSamples:
      - lang: Shell
        source: "curl https://api.lob.com/v1/templates/tmpl_c94e83ca2cd5121 \\\n  -u test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc:\n"
        label: CURL
      - lang: Typescript
        source: "try {\n  const Template = await new TemplatesApi(config).get('tmpl_xxxx');\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: 'This feature is not currently supported by this library.

          '
        label: NODE
      - lang: Ruby
        source: "templateApi = TemplatesApi.new(config)\n\nbegin\n  retrievedTemplate = templateApi.get(\"tmpl_c94e83ca2cd5121\")\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = TemplatesApi(api_client)\n\ntry:\n  template = api.get(\"tmpl_c94e83ca2cd5121\")\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\TemplatesApi($config, new GuzzleHttp\\Client());\n\ntry {\n    $result = $apiInstance->get(\"tmpl_c94e83ca2cd5121\");\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "TemplatesApi apiInstance = new TemplatesApi(config);\n\ntry {\n  Template response = apiInstance.get(\"tmpl_c94e83ca2cd5121\");\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'This feature is not currently supported by this library.

          '
        label: ELIXIR
      - lang: CSharp
        source: "TemplatesApi api = new TemplatesApi(config);\n\ntry {\n  Template response = api.get(\"tmpl_c94e83ca2cd5121\");\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\nfetchedTemplate, _, err := apiClient.TemplatesApi.Get(context,\"tmpl_c94e83ca2cd5121\").Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
    post:
      operationId: template_update
      summary: Update
      description: Updates the description and/or published version of the template with the given id. To update the template's html, create a new version of the template.
      tags:
      - Templates
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/template_update'
            example:
              description: Updated Example
              published_version: vrsn_a
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/template_update'
            example:
              description: Updated Example
              published_version: vrsn_a
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/template_update'
            example:
              description: Updated Example
              published_version: vrsn_a
      responses:
        '200':
          description: Returns the updated template object
          headers:
            ratelimit-limit:
              $ref: '#/components/headers/ratelimit-limit'
            ratelimit-remaining:
              $ref: '#/components/headers/ratelimit-remaining'
            ratelimit-reset:
              $ref: '#/components/headers/ratelimit-reset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/template'
              example:
                id: tmpl_c94e83ca2cd5121
                description: Test Template
                versions:
                - id: vrsn_362184d96d9b0c9
                  suggest_json_editor: true
                  description: Test Template
                  engine: legacy
                  html: <html>HTML for {{name}}</html>
                  date_created: '2017-11-07T22:56:10.962Z'
                  date_modified: '2017-11-07T22:56:10.962Z'
                  object: version
                published_version:
                  id: vrsn_362184d96d9b0c9
                  suggest_json_editor: false
                  description: Test Template
                  engine: handlebars
                  html: <html>HTML for {{name}}</html>
                  date_created: '2017-11-07T22:56:10.962Z'
                  date_modified: '2017-11-07T22:56:10.962Z'
                  object: version
                metadata: {}
                date_created: '2017-11-07T22:56:10.962Z'
                date_modified: '2017-11-07T22:56:10.962Z'
                object: template
        default:
          $ref: '#/components/responses/template_error'
      x-codeSamples:
      - lang: Shell
        source: "curl https://api.lob.com/v1/templates/tmpl_c94e83ca2cd5121 \\\n  -u test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc: \\\n  -d \"description=Updated description\" \\\n  -d \"published_version=vrsn_362184d96d9b0c9\"\n"
        label: CURL
      - lang: Typescript
        source: "const Templates = new TemplatesApi(config);\n\ntry {\n  const updateData = new TemplateUpdate ({\n    description: 'updated template',\n    published_version: 'vrsn_xxxx'\n});\n  const updateTemplate = await Templates.update('tmpl_xxxx', updateData);\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: 'This feature is not currently supported by this library.

          '
        label: NODE
      - lang: Ruby
        source: "templateUpdate = TemplateUpdate.new({\n  description: \"updated template\",\n  published_version: \"vrsn_362184d96d9b0c9\",\n})\n\ntemplateApi = TemplatesApi.new(config)\n\nbegin\n  updatedTemplate = templateApi.update(\"tmpl_c94e83ca2cd5121\", templateUpdate)\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = TemplatesApi(api_client)\n\nupdate_data = TemplateUpdate(\n  description = \"updated template\",\n  published_version = \"vrsn_362184d96d9b0c9\"\n)\n\ntry:\n  update_template = api.update(\"tmpl_c94e83ca2cd5121\", update_data)\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\TemplatesApi($config, new GuzzleHttp\\Client());\n\n$templateUpdate = new OpenAPI\\Client\\Model\\TemplateUpdate(array(\n    \"description\" =>  \"Updated description\",\n    \"published_version\" =>  \"vrsn_362184d96d9b0c9\"\n));\n\ntry {\n    $result = $apiInstance->update(\"tmpl_c94e83ca2cd5121\", $templateUpdate);\n} catch (Exception $e) {\n    echo $e->getMessage(), PHP_EOL;\n}\n"
      - lang: Java
        source: "TemplatesApi apiInstance = new TemplatesApi(config);\nTemplateUpdate update = new TemplateUpdate();\n\nupdate.setDescription(\"update template\");\nupdate.setPublishedVersion(\"vrsn_362184d96d9b0c9\";\n\ntry {\n  apiInstance.update(\"tmpl_c94e83ca2cd5121\", update);\n} catch (ApiException e) {\n  e.printStackTrace();\n}\n"
        label: JAVA
      - lang: Elixir
        source: 'This feature is not currently supported by this library.

          '
        label: ELIXIR
      - lang: CSharp
        source: "TemplatesApi api = new TemplatesApi(config);\nTemplateUpdate update = new TemplateUpdate(\"update template\", \"vrsn_362184d96d9b0c9\");\n\ntry {\n  api.update(\"tmpl_c94e83ca2cd5121\", update);\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 templateWritable = *lob.NewTemplateWritable(\"<html>Updated HTML for Template 1/html>\")\ncreatedTemplate, _, _ := apiClient.TemplatesApi.Create(context).TemplateWritable(templateWritable).Execute()\n\ntemplateWritable.SetDescription(\"Template updated\")\nresp, _, err := apiClient.TemplatesApi.Update(context, createdTemplate.Id).TemplateWritable(templateWritable).Execute()\n\nif err != nil {\n    return err\n}\n"
        label: GO
    delete:
      operationId: template_delete
      summary: Delete
      description: Permanently deletes a template. Deleting a template also deletes its associated versions. Deleted templates can not be used to create postcard, letter, or check resources.
      tags:
      - Templates
      responses:
        '200':
          $ref: '#/components/responses/template_deleted'
        default:
          $ref: '#/components/responses/template_error'
      x-codeSamples:
      - lang: Shell
        source: "curl -X DELETE https://api.lob.com/v1/templates/tmpl_df934eeda694203 \\\n  -u test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc:\n"
        label: CURL
      - lang: Typescript
        source: "try {\n  const deleteTemplate = await new TemplatesApi(config).delete('tmpl_xxxx');\n} catch (err: any) {\n  console.error(err);\n}\n"
        label: TYPESCRIPT
      - lang: Javascript
        source: 'This feature is not currently supported by this library.

          '
        label: NODE
      - lang: Ruby
        source: "templateApi = TemplatesApi.new(config)\n\nbegin\n  deletedTemplate = templateApi.delete(\"tmpl_df934eeda694203\")\nrescue => err\n  p err.message\nend\n"
        label: RUBY
      - lang: Python
        source: "with ApiClient(configuration) as api_client:\n  api = TemplatesApi(api_client)\n\ntry:\n  deleted_resource = api.delete(\"tmpl_df934eeda694203\")\nexcept ApiException as e:\n  print(e)\n"
        label: PYTHON
      - lang: PHP
        source: "$apiInstance = new OpenAPI\\Client\\Api\\TemplatesApi($config, new GuzzleHttp\\Client());\n\ntry {\n    $result = $apiInstance->delete(\"tmpl_df934eeda6

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