:doc:`Connect <../../connect>` / Client / create_contact

**************
create_contact
**************



.. py:method:: Connect.Client.create_contact(**kwargs)

  

  .. warning::

    

    Only the VOICE, EMAIL, and TASK channels are supported.

     

    
    * For VOICE: The supported initiation method is ``TRANSFER``. The contacts created with this initiation method have a subtype ``connect:ExternalAudio``.
     
    * For EMAIL: The supported initiation methods are ``OUTBOUND``, ``AGENT_REPLY``, and ``FLOW``.
     
    * For TASK: The supported initiation method is ``API``. Contacts created with this API have a sub-type of ``connect:ExternalTask``.
    

     

   

  Creates a new VOICE, EMAIL, or TASK contact.

   

  After a contact is created, you can move it to the desired state by using the ``InitiateAs`` parameter. While you can use API to create task contacts that are in the ``COMPLETED`` state, you must contact Amazon Web Services Support before using it for bulk import use cases. Bulk import causes your requests to be throttled or fail if your CreateContact limits aren't high enough.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/connect-2017-08-08/CreateContact>`_  


  **Request Syntax**
  ::

    response = client.create_contact(
        InstanceId='string',
        ClientToken='string',
        RelatedContactId='string',
        Attributes={
            'string': 'string'
        },
        References={
            'string': {
                'Value': 'string',
                'Type': 'URL'|'ATTACHMENT'|'CONTACT_ANALYSIS'|'NUMBER'|'STRING'|'DATE'|'EMAIL'|'EMAIL_MESSAGE'|'EMAIL_MESSAGE_PLAIN_TEXT',
                'Status': 'AVAILABLE'|'DELETED'|'APPROVED'|'REJECTED'|'PROCESSING'|'FAILED',
                'Arn': 'string',
                'StatusReason': 'string'
            }
        },
        Channel='VOICE'|'CHAT'|'TASK'|'EMAIL',
        InitiationMethod='INBOUND'|'OUTBOUND'|'TRANSFER'|'QUEUE_TRANSFER'|'CALLBACK'|'API'|'DISCONNECT'|'MONITOR'|'EXTERNAL_OUTBOUND'|'WEBRTC_API'|'AGENT_REPLY'|'FLOW',
        ExpiryDurationInMinutes=123,
        UserInfo={
            'UserId': 'string'
        },
        InitiateAs='CONNECTED_TO_USER'|'COMPLETED',
        Name='string',
        Description='string',
        SegmentAttributes={
            'string': {
                'ValueString': 'string',
                'ValueMap': {
                    'string': {'... recursive ...'}
                },
                'ValueInteger': 123,
                'ValueList': [
                    {'... recursive ...'},
                ],
                'ValueArn': 'string'
            }
        },
        PreviousContactId='string'
    )
    
  :type InstanceId: string
  :param InstanceId: **[REQUIRED]** 

    The identifier of the Amazon Connect instance. You can `find the instance ID <https://docs.aws.amazon.com/connect/latest/adminguide/find-instance-arn.html>`__ in the Amazon Resource Name (ARN) of the instance.

    

  
  :type ClientToken: string
  :param ClientToken: 

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see `Making retries safe with idempotent APIs <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/>`__.

    This field is autopopulated if not provided.

  
  :type RelatedContactId: string
  :param RelatedContactId: 

    The identifier of the contact in this instance of Amazon Connect.

    

  
  :type Attributes: dict
  :param Attributes: 

    A custom key-value pair using an attribute map. The attributes are standard Amazon Connect attributes, and can be accessed in flows just like any other contact attributes.

     

    There can be up to 32,768 UTF-8 bytes across all key-value pairs per contact. Attribute keys can include only alphanumeric, dash, and underscore characters.

    

  
    - *(string) --* 

    
      - *(string) --* 

      


  :type References: dict
  :param References: 

    A formatted URL that is shown to an agent in the Contact Control Panel (CCP). Tasks can have the following reference types at the time of creation: ``URL`` | ``NUMBER`` | ``STRING`` | ``DATE`` | ``EMAIL`` | ``ATTACHMENT``.

    

  
    - *(string) --* 

    
      - *(dict) --* 

        Well-formed data on a contact, used by agents to complete a contact request. You can have up to 4,096 UTF-8 bytes across all references for a contact.

        

      
        - **Value** *(string) --* 

          A valid value for the reference. For example, for a URL reference, a formatted URL that is displayed to an agent in the Contact Control Panel (CCP).

          

        
        - **Type** *(string) --* **[REQUIRED]** 

          The type of the reference. ``DATE`` must be of type Epoch timestamp.

          

        
        - **Status** *(string) --* 

          Status of the attachment reference type.

          

        
        - **Arn** *(string) --* 

          The Amazon Resource Name (ARN) of the reference

          

        
        - **StatusReason** *(string) --* 

          Relevant details why the reference was not successfully created.

          

        
      


  :type Channel: string
  :param Channel: **[REQUIRED]** 

    The channel for the contact.

     

    .. warning::

       

      The CHAT channel is not supported. The following information is incorrect. We're working to correct it.

      

    

  
  :type InitiationMethod: string
  :param InitiationMethod: **[REQUIRED]** 

    Indicates how the contact was initiated.

     

    .. warning::

       

      CreateContact only supports the following initiation methods. Valid values by channel are:

       

      
      * For VOICE: ``TRANSFER`` and the subtype ``connect:ExternalAudio``
       
      * For EMAIL: ``OUTBOUND`` | ``AGENT_REPLY`` | ``FLOW``
       
      * For TASK: ``API``
      

       

      The other channels listed below are incorrect. We're working to correct this information.

      

    

  
  :type ExpiryDurationInMinutes: integer
  :param ExpiryDurationInMinutes: 

    Number of minutes the contact will be active for before expiring

    

  
  :type UserInfo: dict
  :param UserInfo: 

    User details for the contact

     

    .. warning::

       

      UserInfo is required when creating an EMAIL contact with ``OUTBOUND`` and ``AGENT_REPLY`` contact initiation methods.

      

    

  
    - **UserId** *(string) --* 

      The user identifier for the contact.

      

    
  
  :type InitiateAs: string
  :param InitiateAs: 

    Initial state of the contact when it's created. Only TASK channel contacts can be initiated with ``COMPLETED`` state.

    

  
  :type Name: string
  :param Name: 

    The name of a the contact.

    

  
  :type Description: string
  :param Description: 

    A description of the contact.

    

  
  :type SegmentAttributes: dict
  :param SegmentAttributes: 

    A set of system defined key-value pairs stored on individual contact segments (unique contact ID) using an attribute map. The attributes are standard Amazon Connect attributes. They can be accessed in flows.

     

    Attribute keys can include only alphanumeric, -, and _.

     

    This field can be used to set Segment Contact Expiry as a duration in minutes.

     

    .. note::

      

      To set contact expiry, a ValueMap must be specified containing the integer number of minutes the contact will be active for before expiring, with ``SegmentAttributes`` like { ``"connect:ContactExpiry": {"ValueMap" : { "ExpiryDuration": { "ValueInteger": 135}}}}``.

      

    

  
    - *(string) --* 

    
      - *(dict) --* 

        A value for a segment attribute. This is structured as a map where the key is ``valueString`` and the value is a string.

        

      
        - **ValueString** *(string) --* 

          The value of a segment attribute.

          

        
        - **ValueMap** *(dict) --* 

          The value of a segment attribute.

          

        
          - *(string) --* 

          
            - *(dict) --* 

              A value for a segment attribute. This is structured as a map where the key is ``valueString`` and the value is a string.

              

            
      
    
        - **ValueInteger** *(integer) --* 

          The value of a segment attribute.

          

        
        - **ValueList** *(list) --* 

          The value of a segment attribute. This is only supported for system-defined attributes, not for user-defined attributes.

          

        
          - *(dict) --* 

            A value for a segment attribute. This is structured as a map where the key is ``valueString`` and the value is a string.

            

          
      
        - **ValueArn** *(string) --* 

          The value of a segment attribute that has to be a valid ARN. This is only supported for system-defined attributes, not for user-defined attributes.

          

        
      


  :type PreviousContactId: string
  :param PreviousContactId: 

    The ID of the previous contact when creating a transfer contact. This value can be provided only for external audio contacts. For more information, see `Integrate Amazon Connect Contact Lens with external voice systems <https://docs.aws.amazon.com/connect/latest/adminguide/contact-lens-integration.html>`__ in the *Amazon Connect Administrator Guide*.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'ContactId': 'string',
          'ContactArn': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **ContactId** *(string) --* 

        The identifier of the contact in this instance of Amazon Connect.

        
      

      - **ContactArn** *(string) --* 

        The Amazon Resource Name (ARN) of the created contact.

        
  
  **Exceptions**
  
  *   :py:class:`Connect.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`Connect.Client.exceptions.InternalServiceException`

  
  *   :py:class:`Connect.Client.exceptions.InvalidRequestException`

  
  *   :py:class:`Connect.Client.exceptions.InvalidParameterException`

  
  *   :py:class:`Connect.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`Connect.Client.exceptions.ThrottlingException`

  
  *   :py:class:`Connect.Client.exceptions.IdempotencyException`

  
  *   :py:class:`Connect.Client.exceptions.ConflictException`

  
  *   :py:class:`Connect.Client.exceptions.ServiceQuotaExceededException`

  