> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send a fax

> Send a fax. Files have size limits and page count limit validations. If a file is bigger than 50MB or has more than 350 pages it will fail with `file_size_limit_exceeded` and `page_count_limit_exceeded` respectively. 

**Expected Webhooks:**

- `fax.queued`
- `fax.media.processed`
- `fax.sending.started`
- `fax.delivered`
- `fax.failed`




## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/real-time-communications/fax.yml post /faxes
openapi: 3.1.0
info:
  title: Telnyx Fax API
  version: 2.0.0
  description: API for Fax.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /faxes:
    post:
      tags:
        - Programmable Fax Commands
      summary: Send a fax
      description: >
        Send a fax. Files have size limits and page count limit validations. If
        a file is bigger than 50MB or has more than 350 pages it will fail with
        `file_size_limit_exceeded` and `page_count_limit_exceeded`
        respectively. 


        **Expected Webhooks:**


        - `fax.queued`

        - `fax.media.processed`

        - `fax.sending.started`

        - `fax.delivered`

        - `fax.failed`
      operationId: SendFax
      requestBody:
        description: Send fax request
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SendFaxRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SendFaxMultipartRequest'
      responses:
        '202':
          $ref: '#/components/responses/SendFaxResponse'
        '422':
          $ref: '#/components/responses/programmable-fax_UnprocessableEntityResponse'
        default:
          $ref: '#/components/responses/programmable-fax_GenericErrorResponse'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const fax = await client.faxes.create({
              connection_id: '234423',
              from: '+13125790015',
              to: '+13127367276',
            });

            console.log(fax.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            fax = client.faxes.create(
                connection_id="234423",
                from_="+13125790015",
                to="+13127367276",
            )
            print(fax.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tfax, err := client.Faxes.New(context.TODO(), telnyx.FaxNewParams{\n\t\tConnectionID: \"234423\",\n\t\tFrom:         \"+13125790015\",\n\t\tTo:           \"+13127367276\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", fax.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
            import com.telnyx.sdk.models.faxes.FaxCreateParams;
            import com.telnyx.sdk.models.faxes.FaxCreateResponse;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    FaxCreateParams params = FaxCreateParams.builder()
                        .connectionId("234423")
                        .from("+13125790015")
                        .to("+13127367276")
                        .build();
                    FaxCreateResponse fax = client.faxes().create(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


            telnyx = Telnyx::Client.new(api_key: "My API Key")


            fax = telnyx.faxes.create(connection_id: "234423", from:
            "+13125790015", to: "+13127367276")


            puts(fax)
        - lang: CLI
          source: |-
            telnyx faxes create \
              --api-key 'My API Key' \
              --connection-id 234423 \
              --from +13125790015 \
              --to +13127367276
components:
  schemas:
    SendFaxRequest:
      type: object
      title: Send fax request
      required:
        - connection_id
        - from
        - to
      properties:
        connection_id:
          description: The connection ID to send the fax with.
          type: string
          example: '234423'
        media_url:
          $ref: '#/components/schemas/MediaUrl'
        media_name:
          $ref: '#/components/schemas/MediaName'
        to:
          $ref: '#/components/schemas/To'
        from:
          $ref: '#/components/schemas/From'
        from_display_name:
          description: >-
            The `from_display_name` string to be used as the caller id name (SIP
            From Display Name) presented to the destination (`to` number). The
            string should have a maximum of 128 characters, containing only
            letters, numbers, spaces, and -_~!.+ special characters. If ommited,
            the display name will be the same as the number in the `from` field.
          type: string
          example: Company Name
        quality:
          $ref: '#/components/schemas/Quality'
        t38_enabled:
          description: The flag to disable the T.38 protocol.
          type: boolean
          default: true
        monochrome:
          description: The flag to enable monochrome, true black and white fax results.
          type: boolean
          default: false
        black_threshold:
          description: >-
            The black threshold percentage for monochrome faxes. Only applicable
            if `monochrome` is set to `true`.
          type: integer
          minimum: 1
          maximum: 100
          default: 95
        store_media:
          description: >-
            Should fax media be stored on temporary URL. It does not support
            media_name, they can't be submitted together.
          type: boolean
          default: false
        store_preview:
          description: Should fax preview be stored on temporary URL.
          type: boolean
          default: false
        preview_format:
          description: >-
            The format for the preview file in case the `store_preview` is
            `true`.
          type: string
          enum:
            - pdf
            - tiff
          default: tiff
        webhook_url:
          description: >-
            Use this field to override the URL to which Telnyx will send
            subsequent webhooks for this fax.
          type: string
          example: https://www.example.com/server-b/
        client_state:
          description: >-
            Use this field to add state to every subsequent webhook. It must be
            a valid Base-64 encoded string.
          type: string
          example: aGF2ZSBhIG5pY2UgZGF5ID1d
    SendFaxMultipartRequest:
      type: object
      title: Send fax multipart request
      required:
        - connection_id
        - contents
        - from
        - to
      properties:
        connection_id:
          $ref: '#/components/schemas/ConnectionId'
        contents:
          description: >-
            The file you want to upload. The maximum allowed size is 20 MB.
            contents and media_name/media_url can't be submitted together.
          type: string
          format: binary
        to:
          $ref: '#/components/schemas/To'
        from:
          $ref: '#/components/schemas/From'
        quality:
          $ref: '#/components/schemas/Quality'
        t38_enabled:
          $ref: '#/components/schemas/T38Enabled'
        monochrome:
          $ref: '#/components/schemas/Monochrome'
        store_media:
          $ref: '#/components/schemas/StoreMedia'
        store_preview:
          $ref: '#/components/schemas/StorePreview'
    MediaUrl:
      description: >-
        The URL (or list of URLs) to the PDF used for the fax's media. media_url
        and media_name/contents can't be submitted together.
      type: string
      example: https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf
    MediaName:
      description: >-
        The media_name used for the fax's media. Must point to a file previously
        uploaded to api.telnyx.com/v2/media by the same user/organization.
        media_name and media_url/contents can't be submitted together.
      type: string
      example: my_media_uploaded_to_media_storage_api
    To:
      description: The phone number, in E.164 format, the fax will be sent to or SIP URI
      type: string
      example: '+13127367276'
    From:
      description: The phone number, in E.164 format, the fax will be sent from.
      type: string
      example: '+13125790015'
    Quality:
      description: >-
        The quality of the fax. The `ultra` settings provides the highest
        quality available, but also present longer fax processing times.
        `ultra_light` is best suited for images, wihle `ultra_dark` is best
        suited for text.
      type: string
      example: high
      default: high
      enum:
        - normal
        - high
        - very_high
        - ultra_light
        - ultra_dark
    ConnectionId:
      description: The ID of the connection used to send the fax.
      type: string
      example: '234423'
    T38Enabled:
      description: The flag to disable the T.38 protocol.
      type: boolean
      default: true
    Monochrome:
      description: The flag to enable monochrome, true black and white fax results.
      type: boolean
      default: false
    StoreMedia:
      description: >-
        Should fax media be stored on temporary URL. It does not support
        media_name, they can't be submitted together.
      type: boolean
      default: false
    StorePreview:
      description: Should fax preview be stored on temporary URL.
      type: boolean
      default: false
    Fax:
      type: object
      properties:
        record_type:
          description: Identifies the type of the resource.
          type: string
          example: fax
          enum:
            - fax
        id:
          $ref: '#/components/schemas/Id'
        connection_id:
          $ref: '#/components/schemas/ConnectionId'
        direction:
          $ref: '#/components/schemas/Direction'
        media_url:
          $ref: '#/components/schemas/MediaUrl'
        media_name:
          $ref: '#/components/schemas/MediaName'
        to:
          $ref: '#/components/schemas/To'
        from:
          $ref: '#/components/schemas/From'
        from_display_name:
          description: >-
            The string used as the caller id name (SIP From Display Name)
            presented to the destination (`to` number).
          type: string
          example: Company Name
        quality:
          $ref: '#/components/schemas/Quality'
        status:
          description: Status of the fax
          type: string
          example: queued
          enum:
            - queued
            - media.processed
            - originated
            - sending
            - delivered
            - failed
            - initiated
            - receiving
            - media.processing
            - received
        webhook_url:
          description: URL that will receive fax webhooks
          type: string
        webhook_failover_url:
          description: >-
            Optional failover URL that will receive fax webhooks if webhook_url
            doesn't return a 2XX response
          type: string
        store_media:
          description: >-
            Should fax media be stored on temporary URL. It does not support
            media_name.
          type: boolean
        stored_media_url:
          description: >-
            If store_media was set to true, this is a link to temporary
            location. Link expires after 10 minutes.
          type: string
        preview_url:
          description: >-
            If `store_preview` was set to `true`, this is a link to temporary
            location. Link expires after 10 minutes.
          type: string
        client_state:
          description: State received from a command.
          type: string
          example: aGF2ZSBhIG5pY2UgZGF5ID1d
        created_at:
          description: ISO 8601 timestamp when resource was created
          type: string
          format: date-time
        updated_at:
          description: ISO 8601 timestamp when resource was updated
          type: string
          format: date-time
      example:
        record_type: fax
        id: 0ccc7b54-4df3-4bca-a65a-3da1ecc777f0
        connection_id: c-1
        direction: outbound
        from: '+123'
        to: '+456'
        media_url: http://www.example.com/fax.pdf
        store_media: true
        stored_media_url: >-
          https://s3.amazonaws.com/faxes-dev/user-1/cf4a6b52-bf8e-4945-9f49-611d0d2b083b.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=xxxxxxxxxx%2F20200505%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200505T095917Z&X-Amz-Expires=7200&X-Amz-SignedHeaders=host&X-Amz-Signature=fac2af40464fcc77673ad762db86e34f9c1b91a82699b5578c5327f53874df51
        preview_url: >-
          https://s3.amazonaws.com/faxes-dev/user-1/cf4a6b52-bf8e-4945-9f49-611d0d2b083b_preview.tiff?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=xxxxxxxxxx%2F20200505%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200505T095917Z&X-Amz-Expires=7200&X-Amz-SignedHeaders=host&X-Amz-Signature=fac2af40464fcc77673ad762db86e34f9c1b91a82699b5578c5327f53874df51
        quality: high
        webhook_url: http://www.example.com/webhooks
        webhook_failover_url: ''
        status: queued
        client_state: aGF2ZSBhIG5pY2UgZGF5ID1d
        created_at: '2020-05-05T09:59:12Z'
        updated_at: '2020-05-05T09:59:12Z'
    programmable-fax_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/programmable-fax_Error'
      type: object
    Id:
      type: string
      format: uuid
      example: 0ccc7b54-4df3-4bca-a65a-3da1ecc777f0
      description: Identifies the type of resource.
    Direction:
      description: The direction of the fax.
      type: string
      example: outbound
      enum:
        - inbound
        - outbound
    programmable-fax_Error:
      required:
        - code
        - title
      properties:
        code:
          type: string
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              description: JSON pointer (RFC6901) to the offending entity.
              type: string
            parameter:
              description: Indicates which query parameter caused the error.
              type: string
        meta:
          type: object
          additionalProperties: true
      type: object
  responses:
    SendFaxResponse:
      description: Send fax response
      content:
        application/json:
          schema:
            type: object
            title: Send Fax Response
            properties:
              data:
                $ref: '#/components/schemas/Fax'
    programmable-fax_UnprocessableEntityResponse:
      description: >-
        Unprocessable entity. The request was well-formed but contains semantic
        errors.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/programmable-fax_Errors'
          example:
            errors:
              - code: '422'
                title: Unprocessable Entity
                detail: The request parameters failed validation
    programmable-fax_GenericErrorResponse:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/programmable-fax_Errors'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````