> ## 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.

# Get campaign

> Retrieves a Campaign object.



## OpenAPI

````yaml GET /campaigns/{id}
openapi: 3.1.1
info:
  title: Surge
  version: '1.0'
servers:
  - url: https://api.surge.app
security:
  - authorization: []
paths:
  /campaigns/{id}:
    get:
      tags:
        - Campaigns
      summary: Retrieve a campaign
      description: Retrieves a Campaign object.
      operationId: GetCampaign
      parameters:
        - in: path
          name: id
          required: true
          schema:
            description: The ID of the campaign to retrieve.
            example: cpn_01k0qczvhbet4azgn5xm2ccfst
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Campaign'
          description: Campaign
        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 campaign = await
            client.campaigns.retrieve('cpn_01k0qczvhbet4azgn5xm2ccfst');


            console.log(campaign.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
            )
            campaign = client.campaigns.retrieve(
                "cpn_01k0qczvhbet4azgn5xm2ccfst",
            )
            print(campaign.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\tcampaign, err := client.Campaigns.Get(context.TODO(), \"cpn_01k0qczvhbet4azgn5xm2ccfst\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", campaign.ID)\n}\n"
        - lang: Ruby
          source: >-
            require "surge_api"


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


            campaign =
            surge.campaigns.retrieve("cpn_01k0qczvhbet4azgn5xm2ccfst")


            puts(campaign)
        - 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 {
              $campaign = $client->campaigns->retrieve('cpn_01k0qczvhbet4azgn5xm2ccfst');

              var_dump($campaign);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
components:
  schemas:
    Campaign:
      description: >-
        A campaign represents the context in which one or more of your phone
        numbers communicates with your contacts. Consent and opt-outs are tied
        to the campaign.
      example:
        consent_flow: >-
          When customers bring in their car for service, they will fill out this
          web form for intake: https://fastauto.shop/bp108c In it they can
          choose to opt in to text message notifications. If they choose to opt
          in, we will send them notifications to let them know if our mechanics
          find issues and once the car is ready to go, as well as links to
          invoices and to leave us feedback.
        description: >-
          This phone number will send auto maintenance notifications to end
          users that have opted in. It will also be used for responding to
          customer inquiries and sending some marketing offers.
        id: cpn_01k0qczvhbet4azgn5xm2ccfst
        includes:
          - links
          - phone_numbers
        link_sample: https://l.fastauto.shop/s034ij
        message_samples:
          - >-
            You are now opted in to receive repair notifications from DT
            Precision Auto. Frequency varies. Msg&data rates apply. Reply STOP
            to opt out.
          - >-
            You're lucky that hundred shot of NOS didn't blow the welds on the
            intake!
          - >-
            Your car is ready to go. See your invoice here:
            https://l.fastauto.shop/s034ij
        privacy_policy_url: https://fastauto.shop/sms-privacy
        status: pending
        terms_and_conditions_url: https://fastauto.shop/terms-and-conditions
        use_cases:
          - account_notification
          - customer_care
          - marketing
        volume: high
      properties:
        consent_flow:
          description: >-
            A string explaining the method through which end users will opt in
            to receive messages from the brand. Typically this should include
            URLs for opt-in forms or screenshots that might be helpful in
            explaining the flow to someone unfamiliar with the organization's
            purpose.
          maxLength: 4096
          minLength: 40
          type: string
        description:
          description: >-
            An explanation of the organization's purpose and how it will be
            using text messaging to accomplish that purpose.
          maxLength: 4096
          minLength: 40
          type: string
        id:
          description: The campaign ID
          type: string
        includes:
          description: >
            A list of properties that this campaign should include. These
            properties can be any of the following values:


            - `links` - whether the campaign might send links in messages

            - `phone_numbers` - whether the campaign might send phone numbers in
            messages

            - `age_gated` - whether the campaign contains age gated content
            (controlled substances or adult content)

            - `direct_lending` - whether the campaign contains content related
            to direct lending or other loan arrangements
          items:
            enum:
              - links
              - phone_numbers
              - age_gated
              - direct_lending
            type: string
          type: array
          uniqueItems: true
        link_sample:
          description: >-
            A sample link that might be sent by this campaign. If links from
            other domains are sent through this campaign, they are much more
            likely to be filtered by the carriers. If link shortening is enabled
            for the account, the link shortener URL will be used instead of what
            is provided. Reach out to support if you would like to disable
            automatic link shortening.
          format: uri
          maxLength: 255
          type: string
        message_samples:
          description: >-
            An array of 2-5 strings with examples of the messages that will be
            sent from this campaign. Typically the first sample should be a
            compliance message like `You are now opted in to messages from
            {brand name}. Frequency varies. Msg&data rates apply. Reply STOP to
            opt out.` These samples don't necessarily need to be the only
            templates that will be used for the campaign, but they should
            reflect the purpose of the messages that will be sent. Any variable
            content can be reflected by wrapping it in square brackets like
            `[customer name]`.
          items:
            maxLength: 1024
            minLength: 20
            type: string
          maxItems: 5
          minItems: 2
          type: array
        privacy_policy_url:
          description: >-
            The URL of the privacy policy for the brand in question. This may be
            a shared privacy policy if it's the policy that is displayed to end
            users when they opt in to messaging.
          format: uri
          maxLength: 255
          type: string
        status:
          description: The current status of the campaign.
          enum:
            - active
            - canceled
            - created
            - deactivated
            - in_review
            - rejected
          type: string
        terms_and_conditions_url:
          description: >-
            The URL of the terms and conditions presented to end users when they
            opt in to messaging. These terms and conditions may be shared among
            all of a platform's customers if they're the terms that are
            presented to end users when they opt in to messaging.
          format: uri
          maxLength: 255
          type: string
        use_cases:
          description: >
            A list containing 1-5 types of messages that will be sent with this
            campaign.


            The following use cases are typically available to all brands:


            - `account_notification` - For sending reminders, alerts, and
            general account-related notifications like booking confirmations or
            appointment reminders.

            - `customer_care` - For account support, troubleshooting, and
            general customer service communication.

            - `delivery_notification` - For notifying customers about the status
            of product or service deliveries.

            - `fraud_alert` - For warning customers about suspicious or
            potentially fraudulent activity.

            - `higher_education` - For messaging related to colleges,
            universities, and school districts outside of K–12.

            - `marketing` - For promotional or advertising messages intended to
            market products or services.

            - `polling_voting` - For conducting surveys, polls, or
            voting-related messaging.

            - `public_service_announcement` - For raising awareness about social
            issues or important public information.

            - `security_alert` - For alerts related to potential security
            breaches or compromised systems requiring user action.

            - `two_factor_authentication` - For sending one-time passwords or
            verification codes for login or password reset.


            For access to special use cases not shown here, reach out to
            support@surge.app.
          items:
            enum:
              - account_notification
              - customer_care
              - delivery_notification
              - fraud_alert
              - higher_education
              - marketing
              - polling_voting
              - public_service_announcement
              - security_alert
              - two_factor_authentication
            type: string
          maxItems: 5
          minItems: 1
          type: array
        volume:
          description: >
            This will be one of the following:


            - `low` - The campaign will be allowed to send up to 2000 SMS
            segments to T-Mobile customers each day. In this case your platform
            will be charged for the setup fee for a low volume number upon
            receipt of the API request.

            - `high` - The campaign will be allowed to send up to 200k SMS
            segments to T-Mobile customers each day, depending on the trust
            score assigned by The Campaign Registry. Your platform will be
            charged for the setup fee for a high volume number upon receipt of
            the API request, and phone numbers will be charged as high volume
            numbers going forward.
          enum:
            - high
            - low
          type: string
      required:
        - consent_flow
        - description
        - id
        - includes
        - message_samples
        - privacy_policy_url
        - status
        - use_cases
        - volume
      title: Campaign
      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
    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
  securitySchemes:
    authorization:
      bearerFormat: Surge API token
      scheme: bearer
      type: http

````