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

# Retrieve message

> Retrieves a Message object.



## OpenAPI

````yaml GET /messages/{id}
openapi: 3.1.1
info:
  title: Surge
  version: '1.0'
servers:
  - url: https://api.surge.app
security:
  - authorization: []
paths:
  /messages/{id}:
    get:
      tags:
        - Messages
      summary: Retrieve a message
      description: Retrieves a Message object.
      operationId: GetMessage
      parameters:
        - in: path
          name: id
          required: true
          schema:
            description: The ID of the message to retrieve.
            example: msg_01j9e0m1m6fc38gsv2vkfqgzz2
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
          description: Message
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Surge from '@surgeapi/node';


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


            const message = await
            client.messages.retrieve('msg_01j9e0m1m6fc38gsv2vkfqgzz2');


            console.log(message.id);
        - lang: Python
          source: |-
            import os
            from surge import Surge

            client = Surge(
                api_key=os.environ.get("SURGE_API_KEY"),  # This is the default and can be omitted
            )
            message = client.messages.retrieve(
                "msg_01j9e0m1m6fc38gsv2vkfqgzz2",
            )
            print(message.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/surge-go\"\n\t\"github.com/stainless-sdks/surge-go/option\"\n)\n\nfunc main() {\n\tclient := surge.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmessage, err := client.Messages.Get(context.TODO(), \"msg_01j9e0m1m6fc38gsv2vkfqgzz2\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", message.ID)\n}\n"
        - lang: Ruby
          source: |-
            require "surge_api"

            surge = SurgeAPI::Client.new(api_key: "My API Key")

            message = surge.messages.retrieve("msg_01j9e0m1m6fc38gsv2vkfqgzz2")

            puts(message)
        - lang: PHP
          source: >-
            <?php


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


            use Surge\Client;

            use Surge\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('SURGE_API_KEY') ?: 'My API
            Key');


            try {
              $message = $client->messages->retrieve('msg_01j9e0m1m6fc38gsv2vkfqgzz2');

              var_dump($message);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
components:
  schemas:
    Message:
      description: A Message is a communication sent to a Contact.
      example:
        attachments:
          - id: att_01j9e0m1m6fc38gsv2vkfqgzz2
            type: image
            url: https://api.surge.app/attachments/att_01jbwyqj7rejzat7pq03r7fgmf
        blast_id: null
        body: Thought you could leave without saying goodbye?
        conversation:
          contact:
            first_name: Dominic
            id: ctc_01j9dy8mdzfn3r0e8x1tbdrdrf
            last_name: Toretto
            phone_number: '+18015551234'
          id: cnv_01j9e0dgmdfkj86c877ws0znae
          phone_number:
            id: pn_01jsjwe4d9fx3tpymgtg958d9w
            number: '+18015552345'
            type: local
        id: msg_01j9e0m1m6fc38gsv2vkfqgzz2
        metadata:
          external_id: '12345'
      properties:
        attachments:
          items:
            $ref: '#/components/schemas/Attachment'
          type: array
        blast_id:
          description: >-
            The ID of the blast this message belongs to, if any. This can be
            used to attribute messages back to a specific blast.
          type:
            - string
            - 'null'
        body:
          description: The message body.
          type:
            - string
            - 'null'
        conversation:
          $ref: '#/components/schemas/Conversation'
        id:
          description: Unique identifier for the object.
          type: string
        metadata:
          $ref: '#/components/schemas/Metadata'
      title: Message
      type: object
    ErrorResponse:
      description: An error response
      example:
        error:
          message: The requested resource could not be found.
          type: not_found
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
      title: ErrorResponse
      type: object
    Attachment:
      description: An Attachment is a file that can be sent with a message.
      example:
        id: att_01j9e0m1m6fc38gsv2vkfqgzz2
        type: image
        url: https://api.surge.app/attachments/att_01jbwyqj7rejzat7pq03r7fgmf
      properties:
        id:
          description: Unique identifier for the object.
          type: string
        type:
          description: The type of attachment.
          enum:
            - file
            - image
            - link
            - contact
            - video
          type: string
        url:
          description: The URL of the attachment.
          type: string
      title: Attachment
      type: object
    Conversation:
      description: A conversation with a Contact
      example:
        contact:
          first_name: Dominic
          id: ctc_01j9dy8mdzfn3r0e8x1tbdrdrf
          last_name: Toretto
          phone_number: '+18015551234'
        id: cnv_01j9e0dgmdfkj86c877ws0znae
        phone_number:
          id: pn_01jsjwe4d9fx3tpymgtg958d9w
          name: (801) 555-2345
          number: '+18015552345'
          type: local
      properties:
        contact:
          $ref: '#/components/schemas/Contact'
        id:
          description: Unique identifier for the object.
          type: string
        phone_number:
          $ref: '#/components/schemas/ConversationPhoneNumber'
      required:
        - id
        - contact
      title: Conversation
      type: object
    Metadata:
      additionalProperties:
        maxLength: 500
        type: string
      description: Set of key-value pairs that will be stored with the object.
      maxProperties: 50
      properties: {}
      title: Metadata
      type: object
    Error:
      description: An error response
      example:
        message: The requested resource was not found.
        type: not_found
      properties:
        detail:
          additionalProperties: true
          description: Additional details about the error.
          type: object
        message:
          description: A human-readable error message.
          example: The requested resource was not found.
          type: string
        type:
          description: A unique error code.
          example: not_found
          type: string
      required:
        - type
        - message
      title: Error
      type: object
    Contact:
      description: A contact who has consented to receive messages
      example:
        email: dom@toretto.family
        first_name: Dominic
        id: ctc_01j9dy8mdzfn3r0e8x1tbdrdrf
        last_name: Toretto
        metadata:
          car: 1970 Dodge Charger R/T
        phone_number: '+18015551234'
      properties:
        email:
          description: The contact's email address.
          format: email
          type: string
        first_name:
          description: The contact's first name.
          type: string
        id:
          description: Unique identifier for the object.
          type: string
        last_name:
          description: The contact's last name.
          type: string
        metadata:
          $ref: '#/components/schemas/Metadata'
        phone_number:
          description: The contact's phone number in E.164 format.
          example: '+18015551234'
          format: phone-number
          pattern: ^\+[1-9]\d{6,14}$
          type: string
      required:
        - id
        - phone_number
      title: Contact
      type: object
    ConversationPhoneNumber:
      description: This is the phone number tied to the Surge account.
      example:
        id: pn_01jsjwe4d9fx3tpymgtg958d9w
        name: (801) 555-1234
        number: '+18015551234'
        type: local
      properties:
        id:
          description: Unique identifier for the phone number
          type: string
        name:
          description: A human-readable name for the phone number
          type:
            - string
            - 'null'
        number:
          description: The canonical format of the phone number.
          example: '+18015551234'
          format: phone-number
          pattern: ^\+[1-9]\d{6,14}$|^\d{5,6}$
          type: string
        type:
          description: Whether the phone number is local, toll-free, or short code
          enum:
            - local
            - toll_free
            - short_code
            - demo
          type: string
      required:
        - id
        - name
        - number
        - type
      title: ConversationPhoneNumber
      type: object
  securitySchemes:
    authorization:
      bearerFormat: Surge API token
      scheme: bearer
      type: http

````