:doc:`ManagedGrafana <../../grafana>` / Client / create_workspace_service_account_token

**************************************
create_workspace_service_account_token
**************************************



.. py:method:: ManagedGrafana.Client.create_workspace_service_account_token(**kwargs)

  

  Creates a token that can be used to authenticate and authorize Grafana HTTP API operations for the given `workspace service account <https://docs.aws.amazon.com/grafana/latest/userguide/service-accounts.html>`__. The service account acts as a user for the API operations, and defines the permissions that are used by the API.

   

  .. warning::

     

    When you create the service account token, you will receive a key that is used when calling Grafana APIs. Do not lose this key, as it will not be retrievable again.

     

    If you do lose the key, you can delete the token and recreate it to receive a new key. This will disable the initial key.

     

   

  Service accounts are only available for workspaces that are compatible with Grafana version 9 and above.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/grafana-2020-08-18/CreateWorkspaceServiceAccountToken>`_  


  **Request Syntax**
  ::

    response = client.create_workspace_service_account_token(
        name='string',
        secondsToLive=123,
        serviceAccountId='string',
        workspaceId='string'
    )
    
  :type name: string
  :param name: **[REQUIRED]** 

    A name for the token to create.

    

  
  :type secondsToLive: integer
  :param secondsToLive: **[REQUIRED]** 

    Sets how long the token will be valid, in seconds. You can set the time up to 30 days in the future.

    

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

    The ID of the service account for which to create a token.

    

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

    The ID of the workspace the service account resides within.

    

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

    
    ::

      {
          'serviceAccountId': 'string',
          'serviceAccountToken': {
              'id': 'string',
              'key': 'string',
              'name': 'string'
          },
          'workspaceId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **serviceAccountId** *(string) --* 

        The ID of the service account where the token was created.

        
      

      - **serviceAccountToken** *(dict) --* 

        Information about the created token, including the key. Be sure to store the key securely.

        
        

        - **id** *(string) --* 

          The unique ID of the service account token.

          
        

        - **key** *(string) --* 

          The key for the service account token. Used when making calls to the Grafana HTTP APIs to authenticate and authorize the requests.

          
        

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

          The name of the service account token.

          
    
      

      - **workspaceId** *(string) --* 

        The ID of the workspace where the token was created.

        
  
  **Exceptions**
  
  *   :py:class:`ManagedGrafana.Client.exceptions.ResourceNotFoundException`

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

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

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

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

  
  *   :py:class:`ManagedGrafana.Client.exceptions.InternalServerException`

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

  