openapi: 3.0.0
info:
  title: Letters
  description: Everything about Letters
servers:
  - url: https://rest.clicksend.com
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
  schemas:
    recipient:
      type: object
      properties:
        user_id:
          type: integer
          description: The ID of the user.
          example: 1
        subaccount_id:
          type: integer
          description: The ID of the subaccount.
          example: 1
        message_id:
          type: string
          description: The ID of the message.
          example: A00A1066-BBAE-432B-9B2D-E88969B12C46
        address_name:
          type: string
          description: The name associated with the address.
          example: John Smith
        address_line_1:
          type: string
          description: The first line of the address.
          example: Address 1
        address_line_2:
          type: string
          description: The second line of the address.
          example: ''
        address_city:
          type: string
          description: The city of the address.
          example: CITY
        address_state:
          type: string
          description: The state of the address.
          example: State
        address_postal_code:
          type: string
          description: The postal code of the address.
          example: '123456'
        address_country:
          type: string
          description: The country code of the address.
          example: AU
        return_address_id:
          type: integer
          description: The ID of the return address.
          example: 1
        custom_string:
          type: string
          description: A custom string associated with the message.
          example: kn0ChLhwn6
        schedule:
          type: integer
          description: The schedule timestamp of the message.
          example: 1449573604
        source:
          type: string
          description: The source of the message.
          example: .rest.v3
        colour:
          type: integer
          description: The color setting of the message.
          example: 1
        duplex:
          type: integer
          description: Whether the message is set to duplex printing.
          example: 0
        post_pages:
          type: integer
          description: The number of pages in the postal message.
          example: 7
        post_price:
          type: string
          description: The price of the postal message.
          example: '13.4200'
        priority_post:
          type: integer
          description: Whether the postal message is set to priority.
          example: 0
        date_added:
          type: integer
          description: The timestamp when the message was added.
          example: 1459131623
        status:
          type: string
          description: The status of the message.
          example: SUCCESS
        _file_url:
          type: string
          description: The URL of the file associated with the message.
          example: http://yourdomain.com/file.pdf
        _return_address:
          type: object
          properties:
            return_address_id:
              type: integer
              description: The ID of the return address.
              example: 1
            user_id:
              type: integer
              description: The ID of the user associated with the return address.
              example: 1
            address_name:
              type: string
              description: The name associated with the return address.
              example: John Smith
            address_line_1:
              type: string
              description: The first line of the return address.
              example: Maritime Avenue
            address_line_2:
              type: string
              description: The second line of the return address.
              example: ''
            address_city:
              type: string
              description: The city of the return address.
              example: Flynn
            address_state:
              type: string
              description: The state of the return address.
              example: WA
            address_postal_code:
              type: string
              description: The postal code of the return address.
              example: 6302
            address_country:
              type: string
              description: The country code of the return address.
              example: AU
        _api_username:
          type: string
          description: The API username associated with the message.
          example: my_api_username
    currency:
      type: object
      description: The parameters related to currency.
      properties:
        currency_name_short:
          type: string
          description: >-
            The currency used for the sender in three-letter format (e.g. USD,
            EUR, AUD, NZD, etc).
          example: AUD
        currency_prefix_d:
          type: string
          description: >-
            The symbol used to indicate the currency of the sender (e.g. $ , €,
            etc).
          example: $
        currency_prefix_c:
          type: string
          description: The currency basic unit (e.g. cents).
          example: c
        currency_name_long:
          type: string
          description: The full name of the currency.
          example: Australian Dollars
    send-letter:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Letters queued for delivery.
        data:
          type: object
          properties:
            recipients:
              type: array
              items:
                $ref: '#/components/schemas/recipient'
            _currency:
              $ref: '#/components/schemas/currency'
    calculate-letter-price:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Here are some results.
        data:
          type: object
          properties:
            total_price:
              type: number
              example: 1.87
              description: The total price of the letter.
            total_cost:
              type: number
              example: 1
              description: The total cost of the letter.
            recipients:
              type: array
              items:
                $ref: '#/components/schemas/recipient'
              example:
                - user_id: 1
                  subaccount_id: 1
                  message_id: 06FAD39C-78FD-4D2F-B606-9846D1979F35
                  address_name: John Smith
                  address_line_1: '131'
                  address_line_2: Scheuvront Drive
                  address_city: DENVER
                  address_state: CO
                  address_postal_code: 80202
                  address_country: AU
                  return_address_id: 1
                  schedule: 1449573604
                  post_pages: 3
                  post_price: '1.8700'
                  priority_post: 0
                  date_added: 1449662203
                  status: SUCCESS
    detect-address:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Here is your result.
        data:
          type: object
          properties:
            address_name:
              type: string
              description: The recipient's name.
              example: John Doe
            address_line_1:
              type: string
              description: The first line of the recipient's address.
              example: 123 Main Street
            address_line_2:
              type: string
              description: The second line of the recipient's address (optional).
              example: ''
            address_city:
              type: string
              description: The city of the recipient's address.
              example: Perth
            address_state:
              type: string
              description: The state or region of the recipient's address.
              example: WA
            address_postal_code:
              type: string
              description: The postal code or ZIP code of the recipient's address.
              example: '6000'
            address_country:
              type: string
              description: The country of the recipient's address.
              example: AU
    cancel-scheduled-letter:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Scheduled letter has been cancelled.
        data:
          type: boolean
          example: true
    pagination:
      type: object
      properties:
        total:
          type: integer
          description: The total number of items available for viewing.
          example: 2
        per_page:
          type: integer
          description: >-
            The number of items returned per page. This is specified in the
            limit parameter. You can have 100 items at maximum, and 15 at
            minimum.
          example: 15
        current_page:
          type: integer
          description: The current page number.
          example: 1
        last_page:
          type: integer
          description: The last page number.
          example: 1
        next_page_url:
          type: string
          nullable: true
          description: >-
            A URL of the next page. It will return **null** if there’s no next
            page.
          example: null
        prev_page_url:
          type: string
          nullable: true
          description: >-
            A URL of the previous page. It will return **null** if there’s no
            previous page.
          example: null
        from:
          type: integer
          description: The number of the first result in the current page.
          example: 1
        to:
          type: integer
          description: The number of the last result in the current page.
          example: 2
    view-letter-history:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Here is your history.
        data:
          allOf:
            - $ref: '#/components/schemas/pagination'
            - type: object
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/recipient'
                  example:
                    - user_id: 1
                      subaccount_id: 1
                      message_id: 06FAD39C-78FD-4D2F-B606-9846D1979F35
                      address_name: John Smith
                      address_line_1: '131'
                      address_line_2: Scheuvront Drive
                      address_city: DENVER
                      address_state: CO
                      address_postal_code: 80202
                      address_country: AU
                      return_address_id: 1
                      schedule: 1449573604
                      post_pages: 3
                      post_price: '1.8700'
                      priority_post: 0
                      date_added: 1449662203
                      status: SUCCESS
    export-letter-history:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Download your file here.
        data:
          type: object
          properties:
            url:
              type: string
              description: The URL to download the file.
              example: >-
                https://rest.clicksend.com/files/22D55AF9-6CF0-476D-A8B3-82A998FD2738?filename=export.csv
paths:
  /v3/post/letters/send:
    post:
      summary: Send Letter
      operationId: send-letter
      description: >-
        ### Send letter


        ### **Supported File Types**


        We support `pdf`, `docx` and `doc` files. Contact us to add support for
        any other file type. If you're using `docx` or `doc` files, you'll need
        to convert the file first using our uploads endpoint with the
        querystring parameter `convert=post` e.g. `POST
        https://rest.clicksend.com/v3/uploads?convert=post`. This will return a
        URL to the converted pdf file that can be used in the
        `/post/letters/send` endpoint.


        ### **Letter Specification Guide**


        Follow our [Letter specification
        guide](https://help.clicksend.com/article/wcpkkoou6c-post-letter-template)
        to ensure correct sending and letter template information.


        ### **Letter File Options**


        ### Use existing URL


        With this option, you can use an existing URL to a `pdf` document. For
        example, you might generate the `pdf` on your server.


        When using an existing url make sure that it is publicly accessible as
        it will not work if it is private.


        ### Upload File to Our Server


        With this option, you can use the
        [/uploads](https://developers.clicksend.com/docs/rest/v3/#upload-media-file)
        endpoint to upload the document. The `/uploads` endpoint returns a URL
        that can be used in the `/post/letters/send` endpoint.


        ### Properties


        | Name | Type | Required | Restrictions | Description |

        | --- | --- | --- | --- | --- |

        | file_url | string | true | none | URL of file to send |

        | address_name | string | true | none | Name of address |

        | address_line_1 | string | true | none | First line of address |

        | address_line_2 | string | true | none | Second line of address |

        | address_city | string | true | none | City |

        | address_state | string | true | none | State |

        | address_postal_code | string | true | none | Postal code |

        | address_country | string | true | none | Country |

        | return_address_id | integer(int32) | true | none | ID of return
        address to use |

        | schedule | integer(int32) | false | none | When to send letter
        (0/null=now) |

        | template_used | integer(int1) | false | none | Whether using our
        letter template. Flag value must be 1 for yes or 0 for no. |

        | duplex | integer(int1) | false | none | Whether letter is duplex. Flag
        value must be 1 for yes or 0 for no. |

        | colour | integer(int1) | false | none | Whether letter is in colour.
        Flag value must be 1 for yes or 0 for no. |

        | priority_post | integer(int1) | false | none | Whether letter is
        priority, Flag value must be 1 for yes or 0 for no. |

        | source | string | false | none | Source being sent from |



        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.



        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#authentication" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                file_url:
                  type: string
                template_used:
                  type: integer
                colour:
                  type: integer
                duplex:
                  type: integer
                recipients:
                  type: array
                  items:
                    type: object
                    properties:
                      address_name:
                        type: string
                      address_city:
                        type: string
                      address_state:
                        type: string
                      address_postal_code:
                        type: string
                      address_country:
                        type: string
                      address_line_1:
                        type: string
                      return_address_id:
                        type: string
              example:
                file_url: '{{fileUrl}}'
                template_used: 1
                colour: 0
                duplex: 1
                recipients:
                  - address_name: test
                    address_city: test
                    address_state: test
                    address_postal_code: '6000'
                    address_country: AU
                    address_line_1: 1 test street
                    return_address_id: '{{addressId}}'
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/send-letter'
      x-codeSamples:
        - lang: curl
          source: |-
            curl --include \
                 --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \
                 --request POST \

                 --header "Content-Type: application/json" \
                 --data-binary "{
              \"file_url\": \"http://yourdomain.com/file.pdf\",
              \"template_used\": 1,
              \"colour\": 1,
              \"duplex\": 0,
              \"priority_post\": 0,
              \"recipients\": [
                {
                  \"address_name\": \"My Home Address\",
                  \"address_line_1\": \"Address 1\",
                  \"address_line_2\": \"Address 2\",
                  \"address_city\": \"CITY\",
                  \"address_state\": \"State\",
                  \"address_postal_code\": 123456,
                  \"address_country\": \"AU\",
                  \"return_address_id\": 1,
                  \"custom_string\": \"Custom kn0ChLhwn6\",
                  \"schedule\": 1449573604
                }
              ]
            }" \
            'https://rest.clicksend.com/v3/post/letters/send'
        - lang: PHP
          source: >-
            <?php

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


            // Configure HTTP basic authorization: BasicAuth

            $config = ClickSend\Configuration::getDefaultConfiguration()
                          ->setUsername('USERNAME')
                          ->setPassword('API_KEY');

            $apiInstance = new ClickSend\Api\PostLetterApi(new
            GuzzleHttp\Client(),$config);

            $post_recipient= new \ClickSend\Model\PostRecipient();

            $post_recipient->setAddressName("My Home Address");

            $post_recipient->setAddressLine1("Address 1");

            $post_recipient->setAddressLine2("Address 2");

            $post_recipient->setAddressCity("city");

            $post_recipient->setAddressState("state");

            $post_recipient->setAddressPostalCode("code");

            $post_recipient->setAddressCountry("country");

            $post_recipient->setReturnAddressId(1);

            $post_letter = new \ClickSend\Model\PostLetter(); //
            \ClickSend\Model\PostLetter | PostLetter model

            $post_letter->setFileUrl("http://www.africau.edu/images/default/sample.pdf");

            $post_letter->setPriorityPost(0);

            $post_letter->setRecipients([$post_recipient]);

            $post_letter->setTemplateUsed(1);

            $post_letter->setDuplex(0);

            $post_letter->setColour(1);


            try {
                $result = $apiInstance->postLettersSendPost($post_letter);
                print_r($result);
            } catch (Exception $e) {
                echo 'Exception when calling PostLetterApi->postLettersSendPost: ', $e->getMessage(), PHP_EOL;
            }

            ?>
        - lang: C#
          source: |-
            using IO.ClickSend.ClickSend.Api;
            using IO.ClickSend.Client;
            using IO.ClickSend.ClickSend.Model;

            var configuration = new Configuration()
            {
                Username = USERNAME, 
                Password = API_KEY  
            };
            var postLetterApi = new PostLetterApi(configuration);
            var listOfRecipients = new List<PostRecipient>();
            listOfRecipients.Add(new PostRecipient(
                addressName: "House Address",
                addressLine1: "Address 1",
                addressLine2: "Address 2",
                addressCity: "City",
                addressState: "State",
                addressPostalCode: "Postal Code",
                addressCountry: "US",
                returnAddressId: RETURN_ADDRESS_ID,
                schedule: TimeStamp
            ));
            var response = postLetterApi.PostLettersSendPost(new PostLetter(
                fileUrl: "https://www.yourdomain.com/file.pdf",
                recipients: listOfRecipients,
                templateUsed: 0,
                colour: 0,
                duplex: 0,
                source: "sdk"
            ));
        - lang: Java
          source: |-
            package ClickSend;

            import java.util.Arrays;
            import java.util.List;
            import ClickSend.Api.PostLetterApi;
            import ClickSend.Model.PostLetter;
            import ClickSend.Model.PostRecipient;

            public class send_letter {
              public static void main(String[] args) {
                ApiClient defaultClient = new ApiClient();
                defaultClient.setUsername("USERNAME");
                defaultClient.setPassword("API_KEY");
                PostLetterApi apiInstance = new PostLetterApi(defaultClient);
                PostRecipient recipient= new PostRecipient(); 
                recipient.addressName("name");
                recipient.addressLine1("line1");
                recipient.addressLine2("line2");
                recipient.addressCity("city");
                recipient.addressState("state");
                recipient.addressPostalCode("code");
                recipient.addressCountry("country");
                recipient.returnAddressId(new Integer(1));
                recipient.schedule(new Integer(147852369));
                List<PostRecipient> recipientList=Arrays.asList(recipient);
                PostLetter postLetter = new PostLetter(); // PostLetter | PostLetter model
                postLetter.fileUrl("http://www.africau.edu/images/default/sample.pdf");
                postLetter.templateUsed(new Integer(1));
                postLetter.duplex(new Integer(0));
                postLetter.colour(new Integer(1));
                postLetter.source("source");
                postLetter.recipients(recipientList);
                try {
                    String result = apiInstance.postLettersSendPost(postLetter);
                    System.out.println(result);
                } catch (ApiException e) {
                    System.err.println("Exception when calling PostLetterApi#postLettersSendPost");
                    e.printStackTrace();
                }
              }
            }
        - lang: Node.js
          source: >-
            var api = require('./api.js');


            var letterApi = new api.PostLetterApi("USERNAME", "API_KEY");


            var recipient = new api.PostRecipient();


            recipient.addressName = "My Home Address";

            recipient.addressLine1 = "Address 1";

            recipient.addressLine2 = "Address 2";

            recipient.addressCity = "addressCity";

            recipient.addressState = "addressState";

            recipient.addressPostalCode = "code";

            recipient.addressCountry = "country";

            recipient.returnAddressId = 1;


            var postLetter = new api.PostLetter();


            postLetter.fileUrl =
            "http://www.africau.edu/images/default/sample.pdf";

            postLetter.priorityPost = 0;

            postLetter.recipients = [recipient];

            postLetter.templateUsed = 1;

            postLetter.duplex = 0;

            postLetter.colour = 1;

            postLetter.source = "source";


            letterApi.postLettersSendPost(postLetter).then(function(response) {
              console.log(response.body);
            }).catch(function(err){
              console.error(err.body);
            });
        - lang: Ruby
          source: |-
            # load the gem
            require 'clicksend_client'
            require 'json'

            # setup authorization
            ClickSendClient.configure do |config|
              # Configure HTTP basic authorization: BasicAuth
              config.username = 'USERNAME'
              config.password = 'API_KEY'
            end

            api_instance = ClickSendClient::PostLetterApi.new

            # PostLetter | PostLetter model
            post_letter = ClickSendClient::PostLetter.new(
              "file_url": "file_url",
              "colour": 0,
              "recipients": [
                {
                  "return_address_id": 0,
                  "schedule": 0,
                  "address_postal_code": "address_postal_code",
                  "address_country": "address_country",
                  "address_line_1": "address_line_1",
                  "address_state": "address_state",
                  "address_name": "address_name",
                  "address_line_2": "address_line_2",
                  "address_city": "address_city"
                }
              ],
              "template_used": 0,
              "duplex": 0,
              "priority_post": 0,
              "source": "sdk"
            )

            begin
              # Send post letter
              result = api_instance.post_letters_send_post(post_letter)
              p JSON.parse(result)
            rescue ClickSendClient::ApiError => e
              puts "Exception when calling PostLetterApi->post_letters_send_post: #{e.response_body}"
            end
        - lang: Python
          source: >-
            from __future__ import print_function

            import clicksend_client

            from clicksend_client.rest import ApiException

            from clicksend_client import PostRecipient


            # Configure HTTP basic authorization: BasicAuth

            configuration = clicksend_client.Configuration()

            configuration.username = 'USERNAME'

            configuration.password = 'API_KEY'


            # create an instance of the API class

            api_instance =
            clicksend_client.PostLetterApi(clicksend_client.ApiClient(configuration))

            post_recipient=PostRecipient(
                          address_name="My Home Address",
                          address_line_1="Address 1",
                          address_line_2="Address 2",
                          address_city="CITY",
                          address_state="State",
                          address_postal_code=123456,
                          address_country="AU",
                          return_address_id=1,
                          schedule=1449573604)
            # PostLetter | PostLetter model

            post_letter = clicksend_client.PostLetter(
                          file_url="http://www.africau.edu/images/default/sample.pdf",
                          template_used= 1,
                          colour=1,
                          duplex=0,
                          recipients=[post_recipient]) 

            try:
                # Send post letter
                api_response = api_instance.post_letters_send_post(post_letter)
                print(api_response)
            except ApiException as e:
                print("Exception when calling PostLetterApi->post_letters_send_post: %s\n" % e)
        - lang: perl
          source: >-
            use WWW::ClickSendClient::PostLetterApi;

            use WWW::ClickSendClient::Object::PostLetter;


            my $username = 'YOUR_API_USER_NAME';

            my $password = 'YOUR_API_PASSWORD';


            my $api = WWW::ClickSendClient::PostLetterApi->new(username =>
            $username, password => $password);


            my %params = (
                'file_url'   => 'https://<file_url>',
                'recipients' => [
                    {
                        'return_address_id'   => 0,
                        'schedule'            => 0,
                        'address_postal_code' => 'address_postal_code',
                        'address_country'     => 'AU',
                        'address_line_1'      => 'address_line_1',
                        'address_state'       => 'address_state',
                        'address_name'        => 'address_name',
                        'address_line_2'      => 'address_line_2',
                        'address_city'        => 'address_city'
                    }
                ],
                'template_used' => '0',
                'duplex'        => '0',
                'colour'        => '0',
                'source'        => 'perl-sdk'
            );


            my $post_letter_obj =
            WWW::ClickSendClient::Object::PostLetter->new(%params);

            my $json_output = $api->post_letters_send_post('post_letter'=>
            $post_letter_obj);


            print $json_output;
        - lang: objc
          source: >-
            #import "CSPostLetterApi.h"

            #import "CSDefaultConfiguration.h"


            CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration
            sharedConfig];

            [apiConfig setUsername:@"USERNAME"];

            [apiConfig setPassword:@"PASSWORD"];


            CSPostRecipient *recipient =[[CSPostRecipient alloc] init];

            recipient.addressName = @"address_name";

            recipient.addressLine1 = @"address_line1";

            recipient.addressLine2 = @"address_line2";

            recipient.addressCity = @"address_city";

            recipient.addressState = @"address_state";

            recipient.addressPostalCode = @"address_postalcode";

            recipient.addressCountry = @"address_country";

            recipient.returnAddressId = @(1);

            recipient.schedule = @(0);


            CSPostLetter *postLetter = [[CSPostLetter alloc] init];

            postLetter.fileUrl = @"file_url";

            postLetter.priorityPost = 0;

            postLetter.templateUsed = 0;

            postLetter.duplex = 0;

            postLetter.colour = 0;

            postLetter.source = @"objc";

            postLetter.recipients = [NSArray arrayWithObjects:recipient, nil];


            CSPostLetterApi *postLetterApiInstance = [[CSPostLetterApi alloc]
            init];

            [postLetterApiInstance postLettersSendPostWithPostLetter:postLetter
            completionHandler:^(NSString *output, NSError *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    NSLog(@"%@", output);
                }
            }];
        - lang: swift
          source: >-
            import Alamofire


            let recipients = PostRecipient(addressName: "address_name",
                                           addressLine1: "address_line1",
                                           addressLine2: "address_line@",
                                           addressCity: "address_city",
                                           addressState: "address_State",
                                           addressPostalCode: "address_postalcode",
                                           addressCountry: "address_Country",
                                           returnAddressId: 1,
                                           schedule: nil)

            let postLetter = PostLetter(fileUrl: "file_url",
                                        priorityPost: nil,
                                        recipients: [recipients],
                                        templateUsed: nil,
                                        duplex: nil,
                                        colour: nil,
                                        source: "swift")

            PostLetterAPI.postLettersSendPost(postLetter: postLetter) {
            (dataString, error) in
                guard let dataString = dataString else {
                    print(error!)
                    return
                }
                if let data = dataString.data(using: String.Encoding.utf8) {
                    do {
                        if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
                            print(dictonary)
                        } else {
                            print("Cannot convert the String value to JSON")
                        }
                    } catch let error as NSError {
                    print(error)
                    }
                }
            }
  /v3/post/letters/price:
    post:
      summary: Calculate Letter Price
      operationId: calculate-letter-price
      description: >-
        _Calculate letter price_


        ### Properties


        | Name | Type | Required | Restrictions | Description |

        | --- | --- | --- | --- | --- |

        | file_url | string | true | none | URL of file to send |

        | address_name | string | true | none | Name of address |

        | address_line_1 | string | true | none | First line of address |

        | address_line_2 | string | true | none | Second line of address |

        | address_city | string | true | none | City |

        | address_state | string | true | none | State |

        | address_postal_code | string | true | none | Postal code |

        | address_country | string | true | none | Country |

        | return_address_id | integer(int32) | true | none | ID of return
        address to use |

        | schedule | integer(int32) | false | none | When to send letter
        (0/null=now) |

        | template_used | integer(int1) | false | none | Whether using our
        letter template. Flag value must be 1 for yes or 0 for no. |

        | duplex | integer(int1) | false | none | Whether letter is duplex. Flag
        value must be 1 for yes or 0 for no. |

        | colour | integer(int1) | false | none | Whether letter is in colour.
        Flag value must be 1 for yes or 0 for no. |

        | priority_post | integer(int1) | false | none | Whether letter is
        priority. Flag value must be 1 for yes or 0 for no. |

        | source | string | false | none | Source being sent from |



        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.



        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#authentication" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                file_url:
                  type: string
                template_used:
                  type: integer
                duplex:
                  type: integer
                colour:
                  type: integer
                source:
                  type: string
                recipients:
                  type: array
                  items:
                    type: object
                    properties:
                      address_name:
                        type: string
                      address_city:
                        type: string
                      address_state:
                        type: string
                      address_postal_code:
                        type: string
                      address_country:
                        type: string
                      address_line_1:
                        type: string
                      return_address_id:
                        type: string
              example:
                file_url: >-
                  https://clicksend-api-downloads-dev.s3.ap-southeast-2.amazonaws.com/_private/1DA3BD26-25F5-4B51-900D-C89FE0FCE355.pdf?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=XXXXXXXXXXXXXXXap-southeast-2%2Fs3%2Faws4_request&X-Amz-Date=20240229T053502Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1800&X-Amz-Signature=76ed3e19d416acc7f4bafc00a848badad388104c23d333f16d1047309c743358
                template_used: 0
                duplex: 0
                colour: 0
                source: test
                recipients:
                  - address_name: test
                    address_city: test
                    address_state: test
                    address_postal_code: '6000'
                    address_country: AU
                    address_line_1: 1 test street
                    return_address_id: '1154'
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
        - name: ''
          in: header
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/calculate-letter-price'
      x-codeSamples:
        - lang: curl
          source: |-
            curl --include \
                 --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \
                 --request POST \

                 --header "Content-Type: application/json" \
                 --data-binary "{
              \"file_url\": \"http://yourdomain.com/file.pdf\",
              \"template_used\": 1,
              \"colour\": 1,
              \"duplex\": 0,
              \"priority_post\": 0,
              \"recipients\": [
                {
                  \"address_name\": \"My Home Address\",
                  \"address_line_1\": \"Address 1\",
                  \"address_line_2\": \"Address 2\",
                  \"address_city\": \"CITY\",
                  \"address_state\": \"State\",
                  \"address_postal_code\": 123456,
                  \"address_country\": \"AU\",
                  \"return_address_id\": 1,
                  \"custom_string\": \"Custom kn0ChLhwn6\",
                  \"schedule\": 1449573604
                }
              ]
            }" \
            'https://rest.clicksend.com/v3/post/letters/price'
        - lang: PHP
          source: >-
            <?php

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


            // Configure HTTP basic authorization: BasicAuth

            $config = ClickSend\Configuration::getDefaultConfiguration()
                          ->setUsername('USERNAME')
                          ->setPassword('API_KEY');

            $apiInstance = new ClickSend\Api\PostLetterApi(new
            GuzzleHttp\Client(),$config);

            $post_recipient= new \ClickSend\Model\PostRecipient();

            $post_recipient->setAddressName("My Home Address");

            $post_recipient->setAddressLine1("Address 1");

            $post_recipient->setAddressLine2("Address 2");

            $post_recipient->setAddressCity("city");

            $post_recipient->setAddressState("state");

            $post_recipient->setAddressPostalCode("code");

            $post_recipient->setAddressCountry("country");

            $post_recipient->setReturnAddressId(1);

            $post_letter = new \ClickSend\Model\PostLetter(); //
            \ClickSend\Model\PostLetter | PostLetter model

            $post_letter->setFileUrl("http://www.africau.edu/images/default/sample.pdf");

            $post_letter->setPriorityPost(0);

            $post_letter->setRecipients([$post_recipient]);

            $post_letter->setTemplateUsed(1);

            $post_letter->setDuplex(0);

            $post_letter->setColour(1);


            try {
                $result = $apiInstance->postLettersPricePost($post_letter);
                print_r($result);
            } catch (Exception $e) {
                echo 'Exception when calling PostLetterApi->postLettersPricePost: ', $e->getMessage(), PHP_EOL;
            }

            ?>
        - lang: C#
          source: |-
            using IO.ClickSend.ClickSend.Api;
            using IO.ClickSend.Client;
            using IO.ClickSend.ClickSend.Model;

            var configuration = new Configuration()
            {
                Username = USERNAME, 
                Password = API_KEY  
            };
            var postLetterApi = new PostLetterApi(configuration);
            var listOfRecipients = new List<PostRecipient>();
            listOfRecipients.Add(new PostRecipient(
                addressName: "House Address",
                addressLine1: "Address 1",
                addressLine2: "Address 2",
                addressCity: "City",
                addressState: "State",
                addressPostalCode: "Postal Code",
                addressCountry: "US",
                returnAddressId: RETURN_ADDRESS_ID,
                schedule: TimeStamp
            ));
            var response = postLetterApi.PostLettersPricePost(new PostLetter(
                fileUrl: "https://www.yourdomain.com/file.pdf",
                recipients: listOfRecipients,
                templateUsed: 0,
                colour: 0,
                duplex: 0,
                source: "sdk"
            ));
        - lang: Java
          source: |-
            package ClickSend;

            import java.util.Arrays;
            import java.util.List;
            import ClickSend.Api.PostLetterApi;
            import ClickSend.Model.PostLetter;
            import ClickSend.Model.PostRecipient;

            public class calculate_letter_price {
              public static void main(String[] args) {
                ApiClient defaultClient = new ApiClient();
                defaultClient.setUsername("USERNAME");
                defaultClient.setPassword("API_KEY");
                PostLetterApi apiInstance = new PostLetterApi(defaultClient);
                PostRecipient recipient= new PostRecipient(); 
                recipient.addressName("name");
                recipient.addressLine1("line1");
                recipient.addressLine2("line2");
                recipient.addressCity("city");
                recipient.addressState("state");
                recipient.addressPostalCode("code");
                recipient.addressCountry("country");
                recipient.returnAddressId(new Integer(1));
                recipient.schedule(new Integer(147852369));
                List<PostRecipient> recipientList=Arrays.asList(recipient);
                PostLetter postLetter = new PostLetter(); // PostLetter | PostLetter model
                postLetter.fileUrl("http://www.africau.edu/images/default/sample.pdf");
                postLetter.templateUsed(new Integer(1));
                postLetter.duplex(new Integer(0));
                postLetter.colour(new Integer(1));
                postLetter.source("source");
                postLetter.recipients(recipientList);
                try {
                    String result = apiInstance.postLettersPricePost(postLetter);
                    System.out.println(result);
                } catch (ApiException e) {
                    System.err.println("Exception when calling PostLetterApi#postLettersPricePost");
                    e.printStackTrace();
                }
              }
            }
        - lang: Node.js
          source: >-
            var api = require('./api.js');


            var letterApi = new api.PostLetterApi("USERNAME", "API_KEY");


            var recipient = new api.PostRecipient();


            recipient.addressName = "My Home Address";

            recipient.addressLine1 = "Address 1";

            recipient.addressLine2 = "Address 2";

            recipient.addressCity = "addressCity";

            recipient.addressState = "addressState";

            recipient.addressPostalCode = "code";

            recipient.addressCountry = "country";

            recipient.returnAddressId = 1;


            var postLetter = new api.PostLetter();


            postLetter.fileUrl =
            "http://www.africau.edu/images/default/sample.pdf";

            postLetter.priorityPost = 0;

            postLetter.recipients = [recipient];

            postLetter.templateUsed = 1;

            postLetter.duplex = 0;

            postLetter.colour = 1;

            postLetter.source = "source";


            letterApi.postLettersPricePost(postLetter).then(function(response) {
              console.log(response.body);
            }).catch(function(err){
              console.error(err.body);
            });
        - lang: Ruby
          source: |-
            # load the gem
            require 'clicksend_client'
            require 'json'

            # setup authorization
            ClickSendClient.configure do |config|
              # Configure HTTP basic authorization: BasicAuth
              config.username = 'USERNAME'
              config.password = 'API_KEY'
            end

            api_instance = ClickSendClient::PostLetterApi.new

            # PostLetter | PostLetter model
            post_letter = ClickSendClient::PostLetter.new(
              "file_url": "file_url",
              "colour": 0,
              "recipients": [
                {
                  "return_address_id": 0,
                  "schedule": 0,
                  "address_postal_code": "address_postal_code",
                  "address_country": "address_country",
                  "address_line_1": "address_line_1",
                  "address_state": "address_state",
                  "address_name": "address_name",
                  "address_line_2": "address_line_2",
                  "address_city": "address_city"
                }
              ],
              "template_used": 0,
              "duplex": 0,
              "priority_post": 0,
              "source": "sdk"
            )

            begin
              # Calculate post letter price
              result = api_instance.post_letters_price_post(post_letter)
              p JSON.parse(result)
            rescue ClickSendClient::ApiError => e
              puts "Exception when calling PostLetterApi->post_letters_price_post: #{e.response_body}"
            end
        - lang: Python
          source: >-
            from __future__ import print_function

            import clicksend_client

            from clicksend_client.rest import ApiException

            from clicksend_client import PostRecipient


            # Configure HTTP basic authorization: BasicAuth

            configuration = clicksend_client.Configuration()

            configuration.username = 'USERNAME'

            configuration.password = 'API_KEY'


            # create an instance of the API class

            api_instance =
            clicksend_client.PostLetterApi(clicksend_client.ApiClient(configuration))

            post_recipient=PostRecipient(
                            address_name="My Home Address",
                            address_line_1="Address 1",
                            address_line_2="Address 2",
                            address_city="CITY",
                            address_state="State",
                            address_postal_code=123456,
                            address_country="AU",
                            return_address_id=1,
                            schedule=1449573604)
            # PostLetter | PostLetter model

            post_letter = clicksend_client.PostLetter(
                            file_url="http://www.africau.edu/images/default/sample.pdf",
                            template_used= 1,
                            colour=1,
                            duplex=0,
                            recipients=[post_recipient]) 

            try:
                # Calculate post letter price
                api_response = api_instance.post_letters_price_post(post_letter)
                print(api_response)
            except ApiException as e:
                print("Exception when calling PostLetterApi->post_letters_price_post: %s\n" % e)
        - lang: perl
          source: >-
            use WWW::ClickSendClient::PostLetterApi;

            use WWW::ClickSendClient::Object::PostLetter;


            my $username = 'YOUR_API_USER_NAME';

            my $password = 'YOUR_API_PASSWORD';


            my $api = WWW::ClickSendClient::PostLetterApi->new(username =>
            $username, password => $password);


            my %params = (
                'file_url'   => 'https://<file_url>',
                'recipients' => [
                    {
                        'return_address_id'   => 0,
                        'schedule'            => 0,
                        'address_postal_code' => '123456',
                        'address_country'     => 'AU',
                        'address_line_1'      => 'address_line_1',
                        'address_state'       => 'address_state',
                        'address_name'        => 'address_name',
                        'address_line_2'      => 'address_line_2',
                        'address_city'        => 'address_city'
                    }
                ],
                'template_used' => '0',
                'duplex'        => '0',
                'colour'        => '0',
                'source'        => 'perl-sdk'
            );


            my $post_letter_obj =
            WWW::ClickSendClient::Object::PostLetter->new(%params);

            my $json_output = $api->post_letters_price_post('post_letter'=>
            $post_letter_obj);


            print $json_output;
        - lang: objc
          source: >-
            #import "CSPostLetterApi.h"


            CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration
            sharedConfig];

            [apiConfig setUsername:@"USERNAME"];

            [apiConfig setPasswor


            CSPostRecipient *recipient =[[CSPostRecipient alloc] init];

            recipient.addressName = @"address_name";

            recipient.addressLine1 = @"address_line1";

            recipient.addressLine2 = @"address_line2";

            recipient.addressCity = @"address_city";

            recipient.addressState = @"address_state";

            recipient.addressPostalCode = @"address_postalcode";

            recipient.addressCountry = @"address_country";

            recipient.returnAddressId =nil;

            recipient.schedule =nil;


            CSPostLetter *postLetter = [[CSPostLetter alloc] init];

            postLetter.fileUrl = @"file_url";

            postLetter.priorityPost = 0;

            postLetter.templateUsed = 0;

            postLetter.duplex = 0;

            postLetter.colour = 0;

            postLetter.source = @"objc";

            postLetter.recipients = [NSArray arrayWithObjects:recipient, nil];


            CSPostLetterApi *postLetterApiInstance = [[CSPostLetterApi alloc]
            init];

            [postLetterApiInstance postLettersPricePostWithPostLetter:postLetter
            completionHandler:^(NSString *output, NSError *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    NSLog(@"%@", output);
                }
            }];
        - lang: swift
          source: >-
            import Alamofire


            if let authHeader = Request.authorizationHeader(user: "USERNAME",
            password: "PASSWORD") {
                ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value]
            }


            let recipients = PostRecipient(addressName: "address_name",
                                           addressLine1: "address_line1",
                                           addressLine2: "address_line@",
                                           addressCity: "address_city",
                                           addressState: "address_State",
                                           addressPostalCode: "address_postalcode",
                                           addressCountry: "address_Country",
                                           returnAddressId: 1, schedule: nil)

            let postLetter = PostLetter(fileUrl: "file_url",
                                        priorityPost: nil,
                                        recipients: [recipients],
                                        templateUsed: nil,
                                        duplex: nil,
                                        colour: nil,
                                        source: "swift")

            PostLetterAPI.postLettersPricePost(postLetter: postLetter) {
            (dataString, error) in
                guard let dataString = dataString else {
                    print(error!)
                    return
                }
                if let data = dataString.data(using: String.Encoding.utf8) {
                    do {
                        if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
                            print(dictonary)
                        } else {
                            print("Cannot convert the String value to JSON")
                        }
                    } catch let error as NSError {
                        print(error)
                    }
                }
            }
  /v3/post/letters/detect-address:
    post:
      summary: Detect Address
      operationId: detect-address
      description: >-
        _Detects address in uploaded file._


        The `detect-address` endpoint accepts either a letter in PDF format or
        an address string and attempts to convert it to a standard address
        format. Note that the PDF should be in standard address format, having
        the recipient's name and address listed at the top.


        The endpoint accepts two types of data: 1. A PDF file in `base64`
        encoding. In this case, submit the `base64`\-encoded PDF file contents
        in the `content` field of the request body. 2. An address string. In
        this case, submit the address in a string using the `address` field of
        the request body.


        ### Parameters


        | Parameter | In | Type | Required | Description |

        | --- | --- | --- | --- | --- |

        | convert | query | string | true | none |

        | content | body | string | true | Base64-encoded file contents |



        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.



        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#authentication" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      requestBody:
        content:
          application/json:
            schema:
              type: object
              example:
                content: Q29udGVudHMgb2YgZmlsZQ==
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/detect-address'
      x-codeSamples:
        - lang: curl
          source: |-
            curl --include \
                 --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \
                 --request POST \
                 --header "Content-Type: application/json" \
                 --data-binary "{
                \"content\": \"Q29udGVudHMgb2YgZmlsZQ==\"
            }" \
            'https://rest.clicksend.com/v3/post/letters/detect-address'
        - lang: PHP
          source: >-
            <?php

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


            // Configure HTTP basic authorization: BasicAuth

            $config = ClickSend\Configuration::getDefaultConfiguration()
                          ->setUsername('USERNAME')
                          ->setPassword('API_KEY');

            $apiInstance = new ClickSend\Api\DetectAddressApi(new
            GuzzleHttp\Client(),$config);

            $upload_file = new \ClickSend\Model\UploadFile(); //
            \ClickSend\Model\UploadFile | Your file to be uploaded

            $upload_file->setContent("Q29udGVudHMgb2YgZmlsZQ==");


            try {
                $result = $apiInstance->detectAddressPost($upload_file);
                print_r($result);
            } catch (Exception $e) {
                echo 'Exception when calling DetectAddressApi->detectAddressPost: ', $e->getMessage(), PHP_EOL;
            }

            ?>
        - lang: Java
          source: |-
            package ClickSend;

            import ClickSend.Api.DetectAddressApi;
            import ClickSend.Model.UploadFile;

            public class detect_address {
              public static void main(String[] args) {
                ApiClient defaultClient = new ApiClient();
                defaultClient.setUsername("USERNAME");
                defaultClient.setPassword("API_KEY");
                DetectAddressApi apiInstance = new DetectAddressApi(defaultClient);
                UploadFile uploadFile = new UploadFile(); // UploadFile | Your file to be uploaded
                uploadFile.content("Q29udGVudHMgb2YgZmlsZQ==");
                try {
                    String result = apiInstance.detectAddressPost(uploadFile);
                    System.out.println(result);
                } catch (ApiException e) {
                    System.err.println("Exception when calling DetectAddressApi#detectAddressPost");
                    e.printStackTrace();
                }
              }
            }
        - lang: Node.js
          source: >-
            var api = require('./api.js');


            var detectAddressApi = new api.DetectAddressApi("USERNAME",
            "API_KEY");


            var uploadFile = new api.UploadFile();


            uploadFile.content = "Q29udGVudHMgb2YgZmlsZQ=="


            detectAddressApi.detectAddressPost(uploadFile).then(function(response)
            {
              console.log(response.body);
            }).catch(function(err){
              console.error(err.body);
            });
        - lang: Ruby
          source: |-
            # load the gem
            require 'clicksend_client'
            require 'json'

            # setup authorization
            ClickSendClient.configure do |config|
              # Configure HTTP basic authorization: BasicAuth
              config.username = 'USERNAME'
              config.password = 'API_KEY'
            end

            api_instance = ClickSendClient::DetectAddressApi.new

            # UploadFile | Your file to be uploaded
            upload_file = ClickSendClient::UploadFile.new(
              content: "Q29udGVudHMgb2YgZmlsZQ=="
            )

            begin
              # Detects address in uploaded file.
              result = api_instance.detect_address_post(upload_file)
              p JSON.parse(result)
            rescue ClickSendClient::ApiError => e
              puts "Exception when calling DetectAddressApi->detect_address_post: #{e.response_body}"
            end
        - lang: Python
          source: >-
            from __future__ import print_function

            import clicksend_client

            from clicksend_client.rest import ApiException


            # Configure HTTP basic authorization: BasicAuth

            configuration = clicksend_client.Configuration()

            configuration.username = 'USERNAME'

            configuration.password = 'API_KEY'


            # create an instance of the API class

            api_instance =
            clicksend_client.DetectAddressApi(clicksend_client.ApiClient(configuration))

            content = 'Q29udGVudHMgb2YgZmlsZQ==' # str | Base64-encoded file
            contents

            upload_file = clicksend_client.UploadFile(content = content)

            try:
                # Detects address in uploaded file.
                api_response = api_instance.detect_address_post(upload_file)
                print(api_response)
            except ApiException as e:
                print("Exception when calling DetectAddressApi->detect_address_post: %s\n" % e)
        - lang: perl
          source: >-
            use WWW::ClickSendClient::DetectAddressApi;


            my $username = 'YOUR_API_USER_NAME';

            my $password = 'YOUR_API_PASSWORD';


            my $api = WWW::ClickSendClient::DetectAddressApi->new(username =>
            $username, password => $password);


            my $json_output = $api->detect_address_post('content' =>
            'Q29udGVudHMgb2YgZmlsZQ=='); #Base64-encoded file contents


            print $json_output;
        - lang: objc
          source: >-
            #import "CSDetectAddressApi.h"


            CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration
            sharedConfig];

            [apiConfig setUsername:@"USERNAME"];

            [apiConfig setPassword:@"PASSWORD"];


            CSUploadFile *uploadFile = [[CSUploadFile alloc] init];

            uploadFile.content = @"content";


            CSDetectAddressApi *detectAddressApiInstance = [[CSDetectAddressApi
            alloc] init];

            [detectAddressApiInstance detectAddressPostWithUploadFile:uploadFile
            completionHandler:^(NSString *output, NSError *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    NSLog(@"%@", output);
                }
            }];
        - lang: swift
          source: >-
            import Alamofire


            if let authHeader = Request.authorizationHeader(user: "USERNAME",
            password: "PASSWORD") {
                ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value]
            }


            let uploadFile = UploadFile(content: "content")

            DetectAddressAPI.detectAddressPost(uploadFile: uploadFile) {
            (dataString, error) in
                guard let dataString = dataString else {
                    print(error!)
                    return
                }
                if let data = dataString.data(using: String.Encoding.utf8) {
                    do {
                        if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
                            print(dictonary)
                        } else {
                            print("Cannot convert the String value to JSON")
                        }
                    } catch let error as NSError {
                        print(error)
                    }
                }
            }
  /v3/post/letters/{message_id}/cancel:
    put:
      summary: Cancel Scheduled Letter
      operationId: cancel-scheduled-letter
      description: >-
        _Cancel scheduled letter_


        ### Parameters


        | Parameter | In | Type | Required | Description |

        | --- | --- | --- | --- | --- |

        | message_id | query | string | true | Message ID of the scheduled
        letter that is to be cancelled. |



        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.



        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#authentication" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      requestBody:
        content: {}
      parameters:
        - name: message_id
          in: path
          schema:
            type: string
          required: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/cancel-scheduled-letter'
  /v3/post/letters/history:
    get:
      summary: View Letter History
      operationId: view-letter-history
      description: >-
        _Get all letter history_


        ### Parameters


        | Parameter | In | Type | Required | Description |

        | --- | --- | --- | --- | --- |

        | page | query | integer(int32) | false | [Page number](/#pagination) |

        | limit | query | integer(int32) | false | [Number of records per
        page](/#pagination) |



        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.



        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#authentication" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/view-letter-history'
      x-codeSamples:
        - lang: curl
          source: |-
            curl --include \
                 --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \

            'https://rest.clicksend.com/v3/post/letters/history'
        - lang: PHP
          source: >-
            <?php

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


            // Configure HTTP basic authorization: BasicAuth

            $config = ClickSend\Configuration::getDefaultConfiguration()
                          ->setUsername('USERNAME')
                          ->setPassword('API_KEY');

            $apiInstance = new ClickSend\Api\PostLetterApi(new
            GuzzleHttp\Client(),$config);

            $page = 1; // int | Page number

            $limit = 10; // int | Number of records per page


            try {
                $result = $apiInstance->postLettersHistoryGet($page, $limit);
                print_r($result);
            } catch (Exception $e) {
                echo 'Exception when calling PostLetterApi->postLettersHistoryGet: ', $e->getMessage(), PHP_EOL;
            }

            ?>
        - lang: C#
          source: |-
            using IO.ClickSend.ClickSend.Api;
            using IO.ClickSend.Client;
            using IO.ClickSend.ClickSend.Model;

            var configuration = new Configuration()
            {
                Username = USERNAME, 
                Password = API_KEY  
            };
            var postLetterApi = new PostLetterApi(configuration);
            var response = postLetterApi.PostLettersHistoryGet();
        - lang: Java
          source: |-
            package ClickSend;

            import ClickSend.Api.PostLetterApi;

            public class view_letter_history {
              public static void main(String[] args) {
                ApiClient defaultClient = new ApiClient();
                defaultClient.setUsername("USERNAME");
                defaultClient.setPassword("API_KEY");
                PostLetterApi apiInstance = new PostLetterApi(defaultClient);
                Integer page = 1; // Integer | Page number
                Integer limit = 10; // Integer | Number of records per page
                try {
                    String result = apiInstance.postLettersHistoryGet(page, limit);
                    System.out.println(result);
                } catch (ApiException e) {
                    System.err.println("Exception when calling PostLetterApi#postLettersHistoryGet");
                    e.printStackTrace();
                }
              }
            }
        - lang: Node.js
          source: >-
            var api = require('./api.js');


            var letterApi = new api.PostLetterApi("USERNAME", "API_KEY");


            var page = 1;

            var limit = 10;


            letterApi.postLettersHistoryGet(page, limit).then(function(response)
            {
              console.log(response.body);
            }).catch(function(err){
              console.error(err.body);
            });
        - lang: Ruby
          source: |-
            # load the gem
            require 'clicksend_client'
            require 'json'

            # setup authorization
            ClickSendClient.configure do |config|
              # Configure HTTP basic authorization: BasicAuth
              config.username = 'USERNAME'
              config.password = 'API_KEY'
            end

            api_instance = ClickSendClient::PostLetterApi.new

            opts = {
              page: 1, # Integer | Page number
              limit: 10 # Integer | Number of records per page
            }

            begin
              # Get all post letter history
              result = api_instance.post_letters_history_get(opts)
              p JSON.parse(result)
            rescue ClickSendClient::ApiError => e
              puts "Exception when calling PostLetterApi->post_letters_history_get: #{e.response_body}"
            end
        - lang: Python
          source: >-
            from __future__ import print_function

            import clicksend_client

            from clicksend_client.rest import ApiException


            # Configure HTTP basic authorization: BasicAuth

            configuration = clicksend_client.Configuration()

            configuration.username = 'USERNAME'

            configuration.password = 'API_KEY'


            # create an instance of the API class

            api_instance =
            clicksend_client.PostLetterApi(clicksend_client.ApiClient(configuration))

            page = 1 # int | Page number (optional) (default to 1)

            limit = 10 # int | Number of records per page (optional) (default to
            10)


            try:
                # Get all post letter history
                api_response = api_instance.post_letters_history_get(page=page, limit=limit)
                print(api_response)
            except ApiException as e:
                print("Exception when calling PostLetterApi->post_letters_history_get: %s\n" % e)
        - lang: perl
          source: >-
            use WWW::ClickSendClient::PostLetterApi;


            my $username = 'YOUR_API_USER_NAME';

            my $password = 'YOUR_API_PASSWORD';


            my $api = WWW::ClickSendClient::PostLetterApi->new(username =>
            $username, password => $password);


            my $json_output = $api->post_letters_history_get('page' => '1'
            ,'limit' => '');


            print $json_output;
        - lang: objc
          source: >-
            #import "CSPostLetterApi.h"


            CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration
            sharedConfig];

            [apiConfig setUsername:@"USERNAME"];

            [apiConfig setPassword:@"PASSWORD"];


            NSNumber *page = [[NSNumber alloc] initWithInt:1];

            NSNumber *limit = [[NSNumber alloc] initWithInt:15];


            CSPostLetterApi *postLetterApiInstance = [[CSPostLetterApi alloc]
            init];

            [postLetterApiInstance postLettersHistoryGetWithPage:page
            limit:limit completionHandler:^(NSString *output, NSError *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    NSLog(@"%@", output);
                }
            }];
        - lang: swift
          source: >-
            import Alamofire


            if let authHeader = Request.authorizationHeader(user: "USERNAME",
            password: "PASSWORD") {
                ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value]
            }


            PostLetterAPI.postLettersHistoryGet(page: 1, limit: 15) {
            (dataString, error) in
                guard let dataString = dataString else {
                    print(error!)
                    return
                }
                if let data = dataString.data(using: String.Encoding.utf8) {
                    do {
                        if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
                            print(dictonary)
                        } else {
                            print("Cannot convert the String value to JSON")
                        }
                    } catch let error as NSError {
                        print(error)
                    }
                }
            }
  /v3/post/letters/history/export:
    get:
      summary: Export Letter History
      operationId: export-letter-history
      description: >-
        _export letter history_


        ### Parameters


        | Parameter | In | Type | Required | Description |

        | --- | --- | --- | --- | --- |

        | filename | query | string | true | Filename to export to |



        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.



        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#authentication" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
        - name: filename
          in: query
          schema:
            type: string
          example: Post_history.csv
        - name: q
          in: query
          schema:
            type: string
        - name: order_by
          in: query
          schema:
            type: string
          example: date_added:desc
        - name: date_from
          in: query
          schema:
            type: string
        - name: date_to
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
          example: '50000'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/export-letter-history'
      x-codeSamples:
        - lang: curl
          source: >-
            curl --include \
                 --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \

            'https://rest.clicksend.com/v3/post/letters/history/export?filename={filename}'
        - lang: PHP
          source: >-
            <?php

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


            // Configure HTTP basic authorization: BasicAuth

            $config = ClickSend\Configuration::getDefaultConfiguration()

            ->setUsername('USERNAME')

            ->setPassword('API_KEY');


            $apiInstance = new ClickSend\Api\PostLetterApi(new
            GuzzleHttp\Client(),$config);

            $filename = "filename_example"; // string | Filename to download
            history as


            try {

            $result = $apiInstance->postLettersHistoryExportGet($filename);

            print_r($result);

            } catch (Exception $e) {

            echo 'Exception when calling
            PostLetterApi->PostLettersHistoryExportGet: ', $e->getMessage(),
            PHP_EOL;

            }

            ?>
        - lang: C#
          source: |-
            using IO.ClickSend.ClickSend.Api;
            using IO.ClickSend.Client;
            using IO.ClickSend.ClickSend.Model;

            var configuration = new Configuration()
            {
                Username = USERNAME, 
                Password = API_KEY  
            };
            var postLetterApi = new PostLetterApi(configuration);
            var response = postLetterApi.PostLettersExportGet("filename");
        - lang: Java
          source: |
            package ClickSend;

            import ClickSend.Api.PostLetterApi;

            public class export_letter_history {
              public static void main(String[] args) {
                ApiClient defaultClient = new ApiClient();
                defaultClient.setUsername("USERNAME");
                defaultClient.setPassword("API_KEY");
                PostLetterApi apiInstance = new PostLetterApi(defaultClient);
                String filename = "filename_example"; // String | Filename to export to
                try {
                    String result = apiInstance.postLettersExportGet(filename);
                    System.out.println(result);
                } catch (ApiException e) {
                    System.err.println("Exception when calling PostLetterApi#postLettersExportGet");
                    e.printStackTrace();
                }
              }
            }
        - lang: Node.js
          source: |-
            var api = require('./api.js');

            var letterApi = new api.PostLetterApi("USERNAME", "API_KEY");

            var filename = "filename";

            letterApi.postLettersExportGet(filename).then(function(response) {
              console.log(response.body);
            }).catch(function(err){
              console.error(err.body);
            });
        - lang: Ruby
          source: |-
            # load the gem
            require 'clicksend_client'
            require 'json'

            # setup authorization
            ClickSendClient.configure do |config|
              # Configure HTTP basic authorization: BasicAuth
              config.username = 'USERNAME'
              config.password = 'API_KEY'
            end

            api_instance = ClickSendClient::PostLetterApi.new

            filename = "filename_example" # String | Filename to export to

            begin
              # export post letter history
              result = api_instance.post_letters_export_get(filename)
              p JSON.parse(result)
            rescue ClickSendClient::ApiError => e
              puts "Exception when calling PostLetterApi->post_letters_export_get: #{e.response_body}"
            end
        - lang: Python
          source: >-
            from __future__ import print_function

            import clicksend_client

            from clicksend_client.rest import ApiException


            # Configure HTTP basic authorization: BasicAuth

            configuration = clicksend_client.Configuration()

            configuration.username = 'USERNAME'

            configuration.password = 'API_KEY'


            # create an instance of the API class

            api_instance =
            clicksend_client.PostLetterApi(clicksend_client.ApiClient(configuration))

            filename = 'filename_example' # str | Filename to export to


            try:
                # export post letter history
                api_response = api_instance.post_letters_export_get(filename)
                print(api_response)
            except ApiException as e:
                print("Exception when calling PostLetterApi->post_letters_export_get: %s\n" % e)
        - lang: perl
          source: >-
            use WWW::ClickSendClient::PostLetterApi;


            my $username = 'YOUR_API_USER_NAME';

            my $password = 'YOUR_API_PASSWORD';


            my $api = WWW::ClickSendClient::PostLetterApi->new(username =>
            $username, password => $password);


            my $json_output = $api->post_letters_export_get('filename' =>
            'filename');


            print $json_output;
        - lang: objc
          source: >-
            #import "CSPostLetterApi.h"


            CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration
            sharedConfig];

            [apiConfig setUsername:@"USERNAME"];

            [apiConfig setPassword:@"PASSWORD"];


            CSPostLetterApi *postLetterApiInstance = [[CSPostLetterApi alloc]
            init];

            [postLetterApiInstance postLettersExportGetWithFilename:@"file_name"
            completionHandler:^(NSString *output, NSError *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    NSLog(@"%@", output);
                }
            }];
        - lang: swift
          source: >-
            import Alamofire


            if let authHeader = Request.authorizationHeader(user: "USERNAME",
            password: "PASSWORD") {
                ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value]
            }


            PostLetterAPI.postLettersExportGet(filename: "filename") {
            (dataString, error) in
                guard let dataString = dataString else {
                    print(error!)
                    return
                }
                if let data = dataString.data(using: String.Encoding.utf8) {
                    do {
                        if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
                            print(dictonary)
                        } else {
                            print("Cannot convert the String value to JSON")
                        }
                    } catch let error as NSError {
                        print(error)
                    }
                }
            }
