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

# Assign Messaging Profile To Campaign

> This endpoint allows you to link all phone numbers associated with a Messaging Profile to a campaign. **Please note:** if you want to assign phone numbers to a campaign that you did not create with Telnyx 10DLC services, this endpoint allows that provided that you've shared the campaign with Telnyx. In this case, only provide the parameter, `tcrCampaignId`, and not `campaignId`. In all other cases (where the campaign you're assigning was created with Telnyx 10DLC services), only provide `campaignId`, not `tcrCampaignId`.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/messaging-10dlc/phone-number-campaigns.yml post /10dlc/phoneNumberAssignmentByProfile
openapi: 3.1.0
info:
  title: Telnyx 10DLC Phone Number Campaigns API
  version: 2.0.0
  description: API for 10DLC phone number campaign assignments.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /10dlc/phoneNumberAssignmentByProfile:
    post:
      tags:
        - Bulk Phone Number Campaigns
      summary: Assign Messaging Profile To Campaign
      description: >-
        This endpoint allows you to link all phone numbers associated with a
        Messaging Profile to a campaign. **Please note:** if you want to assign
        phone numbers to a campaign that you did not create with Telnyx 10DLC
        services, this endpoint allows that provided that you've shared the
        campaign with Telnyx. In this case, only provide the parameter,
        `tcrCampaignId`, and not `campaignId`. In all other cases (where the
        campaign you're assigning was created with Telnyx 10DLC services), only
        provide `campaignId`, not `tcrCampaignId`.
      operationId: PostAssignMessagingProfileToCampaign
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AssignProfileToCampaignRequest'
        required: true
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AssignProfileToCampaignResponse'
        '500':
          description: Error searching for phone numbers
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SettingsDataErrorMessage'
        4XX:
          $ref: '#/components/responses/10dlc_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 response = await
            client.messaging10dlc.phoneNumberAssignmentByProfile.assign({
              messagingProfileId: '4001767e-ce0f-4cae-9d5f-0d5e636e7809',
            });


            console.log(response.messagingProfileId);
        - 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
            )

            response =
            client.messaging_10dlc.phone_number_assignment_by_profile.assign(
                messaging_profile_id="4001767e-ce0f-4cae-9d5f-0d5e636e7809",
            )

            print(response.messaging_profile_id)
        - 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\tresponse, err := client.Messaging10dlc.PhoneNumberAssignmentByProfile.Assign(context.TODO(), telnyx.Messaging10dlcPhoneNumberAssignmentByProfileAssignParams{\n\t\tMessagingProfileID: \"4001767e-ce0f-4cae-9d5f-0d5e636e7809\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.MessagingProfileID)\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.messaging10dlc.phonenumberassignmentbyprofile.PhoneNumberAssignmentByProfileAssignParams;

            import
            com.telnyx.sdk.models.messaging10dlc.phonenumberassignmentbyprofile.PhoneNumberAssignmentByProfileAssignResponse;


            public final class Main {
                private Main() {}

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

                    PhoneNumberAssignmentByProfileAssignParams params = PhoneNumberAssignmentByProfileAssignParams.builder()
                        .messagingProfileId("4001767e-ce0f-4cae-9d5f-0d5e636e7809")
                        .build();
                    PhoneNumberAssignmentByProfileAssignResponse response = client.messaging10dlc().phoneNumberAssignmentByProfile().assign(params);
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


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


            response =
            telnyx.messaging_10dlc.phone_number_assignment_by_profile.assign(
              messaging_profile_id: "4001767e-ce0f-4cae-9d5f-0d5e636e7809"
            )


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


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


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


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


            try {
              $response = $client->messaging10dlc->phoneNumberAssignmentByProfile->assign(
                messagingProfileID: '4001767e-ce0f-4cae-9d5f-0d5e636e7809',
                campaignID: '4b300178-131c-d902-d54e-72d90ba1620j',
                tcrCampaignID: 'CWZTFH1',
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx messaging-10dlc:phone-number-assignment-by-profile assign \
              --api-key 'My API Key' \
              --messaging-profile-id 4001767e-ce0f-4cae-9d5f-0d5e636e7809
components:
  schemas:
    AssignProfileToCampaignRequest:
      title: AssignProfileToCampaignRequest
      required:
        - messagingProfileId
      type: object
      properties:
        messagingProfileId:
          title: Messagingprofileid
          type: string
          description: >-
            The ID of the messaging profile that you want to link to the
            specified campaign.
          example: 4001767e-ce0f-4cae-9d5f-0d5e636e7809
        tcrCampaignId:
          title: Tcrcampaignid
          type: string
          description: >-
            The TCR ID of the shared campaign you want to link to the specified
            messaging profile (for campaigns not created using Telnyx 10DLC
            services only). If you supply this ID in the request, do not also
            include a campaignId.
          example: CWZTFH1
        campaignId:
          title: Campaignid
          type: string
          description: >-
            The ID of the campaign you want to link to the specified messaging
            profile. If you supply this ID in the request, do not also include a
            tcrCampaignId.
          example: 4b300178-131c-d902-d54e-72d90ba1620j
    AssignProfileToCampaignResponse:
      title: AssignProfileToCampaignResponse
      required:
        - messagingProfileId
        - taskId
      type: object
      properties:
        messagingProfileId:
          title: Messagingprofileid
          type: string
          description: >-
            The ID of the messaging profile that you want to link to the
            specified campaign.
          example: 4001767e-ce0f-4cae-9d5f-0d5e636e7809
        tcrCampaignId:
          title: Tcrcampaignid
          type: string
          description: >-
            The TCR ID of the shared campaign you want to link to the specified
            messaging profile (for campaigns not created using Telnyx 10DLC
            services only). If you supply this ID in the request, do not also
            include a campaignId.
          example: CWZTFH1
        campaignId:
          title: Campaignid
          type: string
          description: >-
            The ID of the campaign you want to link to the specified messaging
            profile. If you supply this ID in the request, do not also include a
            tcrCampaignId.
          example: 4b300178-131c-d902-d54e-72d90ba1620j
        taskId:
          title: Taskid
          type: string
          description: >-
            The ID of the task associated with assigning a messaging profile to
            a campaign.
          example: 667a80f8-b0a9-49d0-b9ab-a7a1bcc45086
    SettingsDataErrorMessage:
      title: SettingsDataErrorMessage
      required:
        - message
      type: object
      properties:
        message:
          title: Message
          type: string
    10dlc_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/10dlc_Error'
      type: object
    10dlc_Error:
      required:
        - code
        - title
      type: object
      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
  responses:
    10dlc_GenericErrorResponse:
      description: Generic response error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/10dlc_Errors'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````