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

# Add contact

> Adds an existing contact to a manual audience.



## OpenAPI

````yaml POST /audiences/{audience_id}/contacts
openapi: 3.1.1
info:
  title: Surge
  version: '1.0'
servers:
  - url: https://api.surge.app
security:
  - authorization: []
paths:
  /audiences/{audience_id}/contacts:
    post:
      tags:
        - Audiences
      summary: Add a contact to an audience
      description: Adds an existing contact to a manual audience.
      operationId: AddContactToAudience
      parameters:
        - in: path
          name: audience_id
          required: true
          schema:
            description: The audience ID to add the contact to.
            example: aud_01j9a43avnfqzbjfch6pygv1td
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AudienceContactParams'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contact'
          description: The contact, now a member of the audience
        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 contact = await
            client.audiences.addContact('aud_01j9a43avnfqzbjfch6pygv1td', {
              id: 'ctc_01j9dy8mdzfn3r0e8x1tbdrdrf',
            });


            console.log(contact.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
            )
            contact = client.audiences.add_contact(
                audience_id="aud_01j9a43avnfqzbjfch6pygv1td",
                id="ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
            )
            print(contact.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\tcontact, err := client.Audiences.AddContact(\n\t\tcontext.TODO(),\n\t\t\"aud_01j9a43avnfqzbjfch6pygv1td\",\n\t\tsurge.AudienceAddContactParams{\n\t\t\tID: \"ctc_01j9dy8mdzfn3r0e8x1tbdrdrf\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", contact.ID)\n}\n"
        - lang: Ruby
          source: >-
            require "surge_api"


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


            contact =
            surge.audiences.add_contact("aud_01j9a43avnfqzbjfch6pygv1td", id:
            "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf")


            puts(contact)
        - 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 {
              $contact = $client->audiences->addContact(
                'aud_01j9a43avnfqzbjfch6pygv1td', id: 'ctc_01j9dy8mdzfn3r0e8x1tbdrdrf'
              );

              var_dump($contact);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
components:
  schemas:
    AudienceContactParams:
      description: Params for adding an existing contact to a manual audience
      example:
        id: ctc_01j9dy8mdzfn3r0e8x1tbdrdrf
      properties:
        id:
          description: >-
            The ID of the contact to add. The contact must belong to the same
            account as the audience.
          type: string
      required:
        - id
      title: AudienceContactParams
      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
    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
    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
  securitySchemes:
    authorization:
      bearerFormat: Surge API token
      scheme: bearer
      type: http

````