The Workflows standard library modules allow you to easily
construct arguments for services and process responses. There is no need to
import or load libraries in a workflow---library functions work out of the box.

All functions can be called using `call` steps, but only non-blocking functions
can be used inside an expression. For example, HTTP calls, `sys.sleep`, and
`sys.log` cannot be used inside an expression. For more information, see
[Blocking calls](https://docs.cloud.google.com/workflows/docs/reference/syntax/expressions#blocking-calls).

To optimize usage, you should understand which functions are considered a step
and count towards the maximum steps limit. For more information, see
[Optimize usage](https://docs.cloud.google.com/workflows/docs/best-practice#optimize-usage).

Workflows also includes frequently used functions, such as for
data type and format conversions. See
[Expression helpers](https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers).

## Generate random identifiers or numbers

You can use [`uuid.generate`](https://docs.cloud.google.com/workflows/docs/reference/stdlib/uuid/generate)
to return a random 128‑bit universally unique identifier (UUID) in string
form.

You can use
[`sys.now`](https://docs.cloud.google.com/workflows/docs/reference/stdlib/sys/now)
to generate multiple random numbers. (The function returns a floating point
number with nanosecond precision.)

- If you need only one number, use
  [`sys.get_env`](https://docs.cloud.google.com/workflows/docs/reference/stdlib/sys/get_env)
  to retrieve the workflow's execution identifier.

- If a unique ID is needed, you can use `string()` to convert the number
  returned from `sys.now` to a string and combine it with the execution ID; for
  example, `some_execution_id1635892223.4459958`.

Optionally, you can
[use a Cloud Run function to generate a number](https://docs.cloud.google.com/workflows/docs/samples/workflows-functions-randomgen)
and call the Cloud Run function from your workflow.

## Expression helpers

Built-in expression helper functions.

### Conversion functions

Convert values from one data type to another.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers#conversion-functions` | Accepts an attribute of type string or integer and returns a double. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers#conversion-functions` | Accepts an attribute of type string or double and returns an integer. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers#conversion-functions` | Accepts an attribute of type integer, double, or boolean and returns a string. |

### Data type functions

Operate on lists, maps, and strings.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers#datatype-functions` | Checks whether a given key is present in a list or map. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers#datatype-functions` | Accepts an attribute of type map and returns a list of key elements in the map. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers#datatype-functions` | Computes the length of value according to its type. |

### Conditional functions

Support conditions within expressions.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers#conditional-functions` | Returns a value if it is not null; otherwise returns a default value. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers#conditional-functions` | Evaluates a condition and returns one of two arguments depending on what the condition evaluates to. |

### Type functions

Return data type.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/expression-helpers#type_functions` | Returns a string indicating the data type of the argument. |

## Module: base64

Base64 encoding/decoding.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/base64/decode` | Decodes given Base64-encoded string to bytes. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/base64/encode` | Encodes given bytes to Base64 text. |

## Module: events

Events support.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/events/await_callback` | Waits for a callback to be received at the given endpoint. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/events/create_callback_endpoint` | Creates a callback endpoint expecting the specified HTTP method. |

## Module: experimental.executions

Execution management.

> [!CAUTION]
> **Caution:** The behavior of routines in this module might change, and they might not be supported in the future.

Instead of using `experimental.executions.map` to support parallel work, we
recommend you
[execute workflow steps in parallel](https://docs.cloud.google.com/workflows/docs/execute-parallel-steps).
If you are already using `experimental.executions.map`, you can
[migrate your workflow to use parallel steps](https://docs.cloud.google.com/workflows/docs/migrate-function-to-parallel).

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/experimental.executions/execution_error` | Raised when a workflow execution finishes with an error or is cancelled. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/experimental.executions/map` | Starts workflow executions and waits for all of them to finish. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/experimental.executions/run` | Starts a workflow execution and waits for it to finish. |

## Module: hash

Common hashing algorithms.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/hash/compute_checksum` | Computes checksum using a given hashing algorithm. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/hash/compute_hmac` | Computes the hash-based message authentication code (HMAC) for data given a secret key and hashing algorithm. |

## Module: http

HTTP/S request support.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/default_retry_predicate` | Simple default retry predicate for idempotent targets. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/default_retry_predicate_non_idempotent` | Simple default retry predicate for non-idempotent targets. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/delete` | Sends an HTTP `DELETE` request to the specified URL. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/get` | Sends an HTTP `GET` request to the specified URL. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/patch` | Sends an HTTP `PATCH` request to the specified URL. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/post` | Sends an HTTP `POST` request to the specified URL. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/put` | Sends an HTTP `PUT` request to the specified URL. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/request` | Sends an HTTP request. |

| Objects ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/default_retry` | Simple default retry policy for idempotent targets. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/http/default_retry_non_idempotent` | Simple default retry policy for non-idempotent targets. |

## Module: json

JSON encoding/decoding.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/json/decode` | Decodes given JSON bytes (assuming UTF-8), or a string, into an object. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/json/encode` | Encodes given input object to JSON bytes, using UTF-8 charset. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/json/encode_to_string` | Encodes given object to a JSON string. |

## Module: list

List utility.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/list/concat` | Creates a copy of a list with a new element concatenated at the end. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/list/prepend` | Creates a copy of a list with a new element added to the beginning. |

## Module: map

Map utility.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/map/delete` | Takes a map, creates a copy of the map, and removes the item with the specified key. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/map/get` | Performs a safe lookup on a map, returning `null` if the key is not found. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/map/merge` | Takes two maps, creates a copy of the first map, and adds the items from the second map to the copy. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/map/merge_nested` | Takes two maps, creates a copy of the first map, and recursively adds items from the second map to the copy. |

## Module: math

Math utility.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/math/abs` | Returns the absolute value of a number. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/math/floor` | Returns the floor of a number. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/math/max` | Returns the maximum of two numbers. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/math/min` | Returns the minimum of two numbers. |

## Module: retry

Support for retries.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/retry/always` | Convenience retry condition that retries on any error. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/retry/never` | Convenience retry condition that retries on no error at all. |

| Objects ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/retry/default_backoff` | Simple default truncated exponential backoff policy. |

## Module: sys

Common system interface, with platform-dependent implementation.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/sys/get_env` | Retrieves the value of the specified environment variable. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/sys/log` | Writes one of `data`, `text`, or `json` to the log at specified severity. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/sys/now` | Returns Unix time, as a floating-point number. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/sys/sleep` | Suspends execution for the given number of seconds. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/sys/sleep_until` | Suspends execution until the given time. |

## Module: text

Text processing.

To concatenate a string, see
[Strings](https://docs.cloud.google.com/workflows/docs/reference/syntax/strings).

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/decode` | Decodes given data to string, assuming the specified character set. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/encode` | Encodes given text to bytes, using the specified character set. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/find_all` | Finds the index of all instances of a substring in a string. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/find_all_regex` | Finds all matches of a regular expression in a string. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/match_regex` | Reports whether a string contains a match of a regular expression. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/replace_all` | Replaces all instances of a substring with a new string. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/replace_all_regex` | Replaces all matches of a regular expression with a new string. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/split` | Splits the source string into a list of all substrings between each instance of the separator. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/substring` | Extracts the substring between two zero-based indexes of a source string. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/to_lower` | Returns a string with all Unicode letters mapped to their lowercase. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/to_upper` | Returns a string with all Unicode letters mapped to their uppercase. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/url_decode` | Returns a string with pluses and percent-escaped characters converted to UTF-8. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/url_encode` | Returns a string with percent-encoded reserved characters, including spaces. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/text/url_encode_plus` | Returns a string with percent-encoded reserved characters, and spaces replaced by pluses (`+`). |

## Module: time

Time-related utility functions.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/time/format` | Formats the given timestamp as a human-readable string. |
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/time/parse` | Parses the given RFC 3339-compatible string into a timestamp. |

## Module: uuid

UUID utility.

| Functions ||
|---|---|
| `https://docs.cloud.google.com/workflows/docs/reference/stdlib/uuid/generate` | Returns a random universally unique identifier (UUID). |