> ## Documentation Index
> Fetch the complete documentation index at: https://docs.riza.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Retrieve execution

> Retrieves an execution.



## OpenAPI

````yaml get /v1/executions/{id}
openapi: 3.0.3
info:
  title: Execute
  version: 0.1.4
servers:
  - url: https://api.riza.io
security:
  - bearerHttpAuthentication: []
paths:
  /v1/executions/{id}:
    get:
      tags:
        - Execution
      summary: Retrieve execution
      description: Retrieves an execution.
      operationId: retrieveExecution
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Execution'
          description: OK
        '401':
          content:
            application/json:
              examples:
                unauthenticated:
                  value:
                    code: 16
                    message: unauthenticated
              schema:
                $ref: '#/components/schemas/Status'
          description: Unauthenticated error response
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Riza from '@riza-io/api';

            const client = new Riza({
              apiKey: process.env['RIZA_API_KEY'], // This is the default and can be omitted
            });

            const execution = await client.executions.get('id');

            console.log(execution.id);
        - lang: Python
          source: |-
            import os
            from rizaio import Riza

            client = Riza(
                api_key=os.environ.get("RIZA_API_KEY"),  # This is the default and can be omitted
            )
            execution = client.executions.get(
                "id",
            )
            print(execution.id)
        - lang: Go
          source: |
            package main

            import (
              "context"
              "fmt"

              "github.com/riza-io/riza-api-go"
              "github.com/riza-io/riza-api-go/option"
            )

            func main() {
              client := riza.NewClient(
                option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("RIZA_API_KEY")
              )
              execution, err := client.Executions.Get(context.TODO(), "id")
              if err != nil {
                panic(err.Error())
              }
              fmt.Printf("%+v\n", execution.ID)
            }
components:
  schemas:
    Execution:
      properties:
        details:
          $ref: '#/components/schemas/ExecutionDetails'
        duration:
          type: integer
        exit_code:
          type: integer
        id:
          type: string
        language:
          enum:
            - python
            - javascript
            - typescript
            - ruby
            - php
          type: string
        started_at:
          format: date-time
          type: string
      required:
        - id
        - language
        - duration
        - exit_code
        - started_at
      type: object
    Status:
      properties:
        code:
          description: >-
            The status code, which should be an enum value of
            [google.rpc.Code][google.rpc.Code].
          type: integer
        message:
          description: >-
            A developer-facing error message, which should be in English. Any
            user-facing error message should be localized and sent in the
            [google.rpc.Status.details][google.rpc.Status.details] field, or
            localized by the client.
          type: string
      type: object
    ExecutionDetails:
      discriminator:
        mapping:
          function: '#/components/schemas/FunctionExecutionDetails'
          script: '#/components/schemas/ScriptExecutionDetails'
          tool: '#/components/schemas/ToolExecutionDetails'
        propertyName: type
      oneOf:
        - $ref: '#/components/schemas/ToolExecutionDetails'
        - $ref: '#/components/schemas/FunctionExecutionDetails'
        - $ref: '#/components/schemas/ScriptExecutionDetails'
    ToolExecutionDetails:
      properties:
        request:
          $ref: '#/components/schemas/ExecuteToolRequest'
        response:
          $ref: '#/components/schemas/ExecuteToolResponse'
        tool_id:
          type: string
        type:
          enum:
            - tool
          type: string
      required:
        - type
        - tool_id
        - request
        - response
      type: object
    FunctionExecutionDetails:
      properties:
        request:
          $ref: '#/components/schemas/ExecuteFunctionRequest'
        response:
          $ref: '#/components/schemas/ExecuteFunctionResponse'
        type:
          enum:
            - function
          type: string
      required:
        - type
        - request
        - response
      type: object
    ScriptExecutionDetails:
      properties:
        request:
          $ref: '#/components/schemas/ExecuteRequest'
        response:
          $ref: '#/components/schemas/ExecuteResponse'
        type:
          enum:
            - script
          type: string
      required:
        - type
        - request
        - response
      type: object
    ExecuteToolRequest:
      properties:
        env:
          description: Set of key-value pairs to add to the tool's execution environment.
          items:
            $ref: '#/components/schemas/EnvVar'
          type: array
        http:
          $ref: '#/components/schemas/HTTPTool'
        input:
          description: >-
            The input to the tool. This must be a valid JSON-serializable
            object. It will be validated against the tool's input schema.
        revision_id:
          description: >-
            The Tool revision ID to execute. This optional parmeter is used to
            pin executions to specific versions of the Tool. If not provided,
            the latest (current) version of the Tool will be executed.
          type: string
      type: object
    ExecuteToolResponse:
      properties:
        execution:
          $ref: '#/components/schemas/ExecutionResult'
        output:
          description: The returned value of the Tool's execute function.
        output_status:
          description: >-
            The status of the output. "valid" means your Tool executed
            successfully and returned a valid JSON-serializable object, or void.
            "json_serialization_error" means your Tool executed successfully,
            but returned a nonserializable object. "error" means your Tool
            failed to execute.
          enum:
            - error
            - json_serialization_error
            - valid
          type: string
      required:
        - output
        - output_status
        - execution
      type: object
    ExecuteFunctionRequest:
      properties:
        code:
          description: >-
            The function to execute. Your code must define a function named
            "execute" that takes in a single argument and returns a
            JSON-serializable value.
          type: string
        env:
          additionalProperties:
            type: string
          description: >-
            Set of key-value pairs to add to the function's execution
            environment.
          type: object
        files:
          description: List of input files.
          items:
            $ref: '#/components/schemas/File'
          type: array
        http:
          $ref: '#/components/schemas/HTTP'
        input:
          description: >-
            The input to the function. This must be a valid JSON-serializable
            object. If you do not pass an input, your function will be called
            with None (Python) or null (JavaScript/TypeScript) as the argument.
        language:
          description: The interpreter to use when executing code.
          enum:
            - python
            - javascript
            - typescript
          type: string
        limits:
          $ref: '#/components/schemas/Limits'
        runtime_revision_id:
          description: The ID of the runtime revision to use when executing code.
          type: string
      required:
        - language
        - code
      type: object
    ExecuteFunctionResponse:
      properties:
        execution:
          $ref: '#/components/schemas/ExecutionResult'
        output:
          description: The output of the function.
        output_status:
          description: >-
            The status of the output. "valid" means your function executed
            successfully and returned a valid JSON-serializable object, or void.
            "json_serialization_error" means your function executed
            successfully, but returned a nonserializable object. "error" means
            your function failed to execute.
          enum:
            - error
            - json_serialization_error
            - valid
          type: string
      required:
        - output
        - output_status
        - execution
      type: object
    ExecuteRequest:
      properties:
        args:
          description: List of command line arguments to pass to the script.
          items:
            type: string
          type: array
        code:
          description: The code to execute.
          type: string
        env:
          additionalProperties:
            type: string
          description: Set of key-value pairs to add to the script's execution environment.
          type: object
        files:
          description: List of input files.
          items:
            $ref: '#/components/schemas/File'
          type: array
        http:
          $ref: '#/components/schemas/HTTP'
        language:
          description: The interpreter to use when executing code.
          enum:
            - python
            - javascript
            - typescript
            - ruby
            - php
          type: string
        limits:
          $ref: '#/components/schemas/Limits'
        runtime_revision_id:
          description: The ID of the runtime revision to use when executing code.
          type: string
        stdin:
          description: Input made available to the script via 'stdin'.
          type: string
      required:
        - language
        - code
      type: object
    ExecuteResponse:
      properties:
        duration:
          description: The execution time of the script in milliseconds.
          type: integer
        exit_code:
          description: >-
            The exit code returned by the script. Will often be '0' on success
            and non-zero on failure.
          type: integer
        id:
          description: The ID of the execution.
          type: string
        stderr:
          description: The contents of 'stderr' after executing the script.
          type: string
        stdout:
          description: The contents of 'stdout' after executing the script.
          type: string
      required:
        - id
        - exit_code
        - stdout
        - stderr
        - duration
      type: object
    EnvVar:
      description: Set of key-value pairs to add to the tool's execution environment.
      properties:
        name:
          type: string
        secret_id:
          type: string
        value:
          type: string
      required:
        - name
      type: object
    HTTPTool:
      description: Configuration for HTTP requests and authentication.
      properties:
        allow:
          description: List of allowed HTTP hosts and associated authentication.
          items:
            $ref: '#/components/schemas/HTTPToolAllow'
          type: array
      type: object
    ExecutionResult:
      description: The execution details of the function.
      properties:
        duration:
          description: The execution time of the function in milliseconds.
          type: integer
        exit_code:
          description: >-
            The exit code returned by the function. Will often be '0' on success
            and non-zero on failure.
          type: integer
        id:
          description: The ID of the execution.
          type: string
        stderr:
          description: The contents of 'stderr' after executing the function.
          type: string
        stdout:
          description: The contents of 'stdout' after executing the function.
          type: string
      required:
        - id
        - exit_code
        - stdout
        - stderr
        - duration
      type: object
    File:
      properties:
        contents:
          description: The contents of the file.
          type: string
        path:
          description: The relative path of the file.
          type: string
      type: object
    HTTP:
      description: Configuration for HTTP requests and authentication.
      properties:
        allow:
          description: List of allowed HTTP hosts and associated authentication.
          items:
            $ref: '#/components/schemas/HTTPAllow'
          type: array
      type: object
    Limits:
      description: Configuration for execution environment limits.
      properties:
        execution_timeout:
          description: The maximum time allowed for execution (in seconds). Default is 30.
          type: integer
        memory_size:
          description: The maximum memory allowed for execution (in MiB). Default is 128.
          type: integer
      type: object
    HTTPToolAllow:
      description: List of allowed HTTP hosts and associated authentication.
      properties:
        auth:
          $ref: '#/components/schemas/HTTPToolAuth'
        host:
          description: The hostname to allow.
          type: string
      type: object
    HTTPAllow:
      description: List of allowed HTTP hosts and associated authentication.
      properties:
        auth:
          $ref: '#/components/schemas/HTTPAuth'
        host:
          description: The hostname to allow.
          type: string
      type: object
    HTTPToolAuth:
      description: Authentication configuration for outbound requests to this host.
      properties:
        basic:
          $ref: '#/components/schemas/HTTPToolBasic'
        bearer:
          $ref: '#/components/schemas/HTTPToolBearer'
        query:
          $ref: '#/components/schemas/HTTPToolQuery'
      type: object
    HTTPAuth:
      description: Authentication configuration for outbound requests to this host.
      properties:
        basic:
          $ref: '#/components/schemas/HTTPBasic'
        bearer:
          $ref: '#/components/schemas/HTTPBearer'
        header:
          $ref: '#/components/schemas/HTTPHeader'
        query:
          $ref: '#/components/schemas/HTTPQuery'
      type: object
    HTTPToolBasic:
      properties:
        password:
          type: string
        secret_id:
          type: string
        user_id:
          type: string
      type: object
    HTTPToolBearer:
      description: >-
        Configuration to add an 'Authorization' header using the 'Bearer'
        scheme.
      properties:
        secret_id:
          type: string
        token:
          description: 'The token to set, e.g. ''Authorization: Bearer <token>''.'
          type: string
      type: object
    HTTPToolQuery:
      properties:
        key:
          type: string
        secret_id:
          type: string
        value:
          type: string
      type: object
    HTTPBasic:
      properties:
        password:
          type: string
        user_id:
          type: string
      type: object
    HTTPBearer:
      description: >-
        Configuration to add an 'Authorization' header using the 'Bearer'
        scheme.
      properties:
        token:
          description: 'The token to set, e.g. ''Authorization: Bearer <token>''.'
          type: string
      type: object
    HTTPHeader:
      properties:
        name:
          type: string
        value:
          type: string
      type: object
    HTTPQuery:
      properties:
        key:
          type: string
        value:
          type: string
      type: object
  securitySchemes:
    bearerHttpAuthentication:
      scheme: bearer
      type: http

````