:doc:`BedrockAgentCore <../../bedrock-agentcore>` / Client / create_event

************
create_event
************



.. py:method:: BedrockAgentCore.Client.create_event(**kwargs)

  

  Creates an event in an AgentCore Memory resource. Events represent interactions or activities that occur within a session and are associated with specific actors.

   

  To use this operation, you must have the ``bedrock-agentcore:CreateEvent`` permission.

   

  This operation is subject to request rate limiting.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/bedrock-agentcore-2024-02-28/CreateEvent>`_  


  **Request Syntax**
  ::

    response = client.create_event(
        memoryId='string',
        actorId='string',
        sessionId='string',
        eventTimestamp=datetime(2015, 1, 1),
        payload=[
            {
                'conversational': {
                    'content': {
                        'text': 'string'
                    },
                    'role': 'ASSISTANT'|'USER'|'TOOL'|'OTHER'
                },
                'blob': {...}|[...]|123|123.4|'string'|True|None
            },
        ],
        branch={
            'rootEventId': 'string',
            'name': 'string'
        },
        clientToken='string',
        metadata={
            'string': {
                'stringValue': 'string'
            }
        }
    )
    
  :type memoryId: string
  :param memoryId: **[REQUIRED]** 

    The identifier of the AgentCore Memory resource in which to create the event.

    

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

    The identifier of the actor associated with this event. An actor represents an entity that participates in sessions and generates events.

    

  
  :type sessionId: string
  :param sessionId: 

    The identifier of the session in which this event occurs. A session represents a sequence of related events.

    

  
  :type eventTimestamp: datetime
  :param eventTimestamp: **[REQUIRED]** 

    The timestamp when the event occurred. If not specified, the current time is used.

    

  
  :type payload: list
  :param payload: **[REQUIRED]** 

    The content payload of the event. This can include conversational data or binary content.

    

  
    - *(dict) --* 

      Contains the payload content for an event.

      .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``conversational``, ``blob``. 

    
      - **conversational** *(dict) --* 

        The conversational content of the payload.

        

      
        - **content** *(dict) --* **[REQUIRED]** 

          The content of the conversation message.

          .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``text``. 

        
          - **text** *(string) --* 

            The text content of the memory item.

            

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

          The role of the participant in the conversation (for example, "user" or "assistant").

          

        
      
      - **blob** (:ref:`document<document>`) -- 

        The binary content of the payload.

        

      
    

  :type branch: dict
  :param branch: 

    The branch information for this event. Branches allow for organizing events into different conversation threads or paths.

    

  
    - **rootEventId** *(string) --* 

      The identifier of the root event for this branch.

      

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

      The name of the branch.

      

    
  
  :type clientToken: string
  :param clientToken: 

    A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, AgentCore ignores the request, but does not return an error.

    This field is autopopulated if not provided.

  
  :type metadata: dict
  :param metadata: 

    The key-value metadata to attach to the event.

    

  
    - *(string) --* 

    
      - *(dict) --* 

        Value associated with the ``eventMetadata`` key.

        .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``stringValue``. 

      
        - **stringValue** *(string) --* 

          Value associated with the ``eventMetadata`` key.

          

        
      


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

    
    ::

      {
          'event': {
              'memoryId': 'string',
              'actorId': 'string',
              'sessionId': 'string',
              'eventId': 'string',
              'eventTimestamp': datetime(2015, 1, 1),
              'payload': [
                  {
                      'conversational': {
                          'content': {
                              'text': 'string'
                          },
                          'role': 'ASSISTANT'|'USER'|'TOOL'|'OTHER'
                      },
                      'blob': {...}|[...]|123|123.4|'string'|True|None
                  },
              ],
              'branch': {
                  'rootEventId': 'string',
                  'name': 'string'
              },
              'metadata': {
                  'string': {
                      'stringValue': 'string'
                  }
              }
          }
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **event** *(dict) --* 

        The event that was created.

        
        

        - **memoryId** *(string) --* 

          The identifier of the AgentCore Memory resource containing the event.

          
        

        - **actorId** *(string) --* 

          The identifier of the actor associated with the event.

          
        

        - **sessionId** *(string) --* 

          The identifier of the session containing the event.

          
        

        - **eventId** *(string) --* 

          The unique identifier of the event.

          
        

        - **eventTimestamp** *(datetime) --* 

          The timestamp when the event occurred.

          
        

        - **payload** *(list) --* 

          The content payload of the event.

          
          

          - *(dict) --* 

            Contains the payload content for an event.

            .. note::    This is a Tagged Union structure. Only one of the     following top level keys will be set: ``conversational``, ``blob``.     If a client receives an unknown member it will     set ``SDK_UNKNOWN_MEMBER`` as the top level key,     which maps to the name or tag of the unknown     member. The structure of ``SDK_UNKNOWN_MEMBER`` is     as follows::

                        'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}


          
            

            - **conversational** *(dict) --* 

              The conversational content of the payload.

              
              

              - **content** *(dict) --* 

                The content of the conversation message.

                .. note::    This is a Tagged Union structure. Only one of the     following top level keys will be set: ``text``.     If a client receives an unknown member it will     set ``SDK_UNKNOWN_MEMBER`` as the top level key,     which maps to the name or tag of the unknown     member. The structure of ``SDK_UNKNOWN_MEMBER`` is     as follows::

                                'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}


              
                

                - **text** *(string) --* 

                  The text content of the memory item.

                  
            
              

              - **role** *(string) --* 

                The role of the participant in the conversation (for example, "user" or "assistant").

                
          
            

            - **blob** (:ref:`document<document>`) -- 

              The binary content of the payload.

              
        
      
        

        - **branch** *(dict) --* 

          The branch information for the event.

          
          

          - **rootEventId** *(string) --* 

            The identifier of the root event for this branch.

            
          

          - **name** *(string) --* 

            The name of the branch.

            
      
        

        - **metadata** *(dict) --* 

          Metadata associated with an event.

          
          

          - *(string) --* 
            

            - *(dict) --* 

              Value associated with the ``eventMetadata`` key.

              .. note::    This is a Tagged Union structure. Only one of the     following top level keys will be set: ``stringValue``.     If a client receives an unknown member it will     set ``SDK_UNKNOWN_MEMBER`` as the top level key,     which maps to the name or tag of the unknown     member. The structure of ``SDK_UNKNOWN_MEMBER`` is     as follows::

                            'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}


            
              

              - **stringValue** *(string) --* 

                Value associated with the ``eventMetadata`` key.

                
          
      
    
    
  
  **Exceptions**
  
  *   :py:class:`BedrockAgentCore.Client.exceptions.ServiceQuotaExceededException`

  
  *   :py:class:`BedrockAgentCore.Client.exceptions.ThrottledException`

  
  *   :py:class:`BedrockAgentCore.Client.exceptions.ServiceException`

  
  *   :py:class:`BedrockAgentCore.Client.exceptions.RetryableConflictException`

  
  *   :py:class:`BedrockAgentCore.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`BedrockAgentCore.Client.exceptions.ValidationException`

  
  *   :py:class:`BedrockAgentCore.Client.exceptions.InvalidInputException`

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

  