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

# Create Endpoint Connection

> Create a new endpoint connection for a product.

## Returns

Returns an [Endpoint Connection](/concepts/product/endpoint-connection) object for the given parameters, or `None` if an error occurs.

## Example

```python theme={"system"}
endpoint_connection = galtea.endpoint_connections.create(
    name="production-chat-api-" + run_identifier,
    product_id=product_id,
    url="https://api.example.com/v1/chat",
    type=EndpointConnectionType.CONVERSATION,
    http_method="POST",
    auth_type="BEARER",
    auth_token="YOUR_AUTH_TOKEN",
    input_template='{"message": "{{ input.user_message }}"}',
    output_mapping={"output": "$.response"},
    timeout=30,
)
```

## Parameters

<ResponseField name="name" type="string" required>
  Name of the endpoint connection. Must be unique per product.
</ResponseField>

<ResponseField name="product_id" type="string" required>
  ID of the product this connection belongs to.
</ResponseField>

<ResponseField name="url" type="string" required>
  The endpoint URL (HTTPS only). For [multi-step session lifecycles](/concepts/product/endpoint-connection#multi-step-session-lifecycle-advanced), the URL supports a `{{ session_id }}` placeholder for dynamic session IDs (e.g., `https://api.example.com/v1/threads/{{ session_id }}/messages`). Only available when an `INITIALIZATION` endpoint connection returns a `session_id`.
</ResponseField>

<ResponseField name="type" type="string" required>
  Type of endpoint connection. Valid values: `INITIALIZATION`, `CONVERSATION`, `FINALIZATION`.
  `CONVERSATION` is required for all products. `INITIALIZATION` and `FINALIZATION` are only needed
  for [complex session management](/concepts/product/endpoint-connection#multi-step-session-lifecycle-advanced)
  (e.g., when your API requires a separate setup call that returns a session ID, or a cleanup call
  after the conversation ends).
</ResponseField>

<ResponseField name="http_method" type="string" default="POST">
  HTTP method. Valid values: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`. Defaults to `POST`.
</ResponseField>

<ResponseField name="auth_type" type="string" default="BEARER">
  Authentication type. Valid values: `NONE`, `BEARER`, `API_KEY`, `BASIC`. Defaults to `BEARER`.
</ResponseField>

<ResponseField name="auth_token" type="string" optional>
  Authentication token. Required for `BEARER` and `API_KEY` auth types.
</ResponseField>

<ResponseField name="username" type="string" optional>
  Username for `BASIC` authentication.
</ResponseField>

<ResponseField name="password" type="string" optional>
  Password for `BASIC` authentication.
</ResponseField>

<ResponseField name="headers" type="dict[string, string]" optional>
  Custom headers as key-value pairs. Supports credential placeholders (e.g., `{{ bearer_token }}`, `{{ api_key }}`). See [Custom Headers](/concepts/product/endpoint-connection-configuration#custom-headers).
</ResponseField>

<ResponseField name="input_template" type="string" optional>
  Input template with Jinja2 placeholders. Required for `CONVERSATION` type. Must contain `{{ input.user_message }}`. See [Templates & Mapping](/concepts/product/endpoint-connection-configuration#input-template).
</ResponseField>

<ResponseField name="output_mapping" type="dict[string, string]" optional>
  Output mapping configuration using JSONPath expressions. Required for `INITIALIZATION` (needs `session_id`) and `CONVERSATION` (needs `output`) types. See [Templates & Mapping](/concepts/product/endpoint-connection-configuration#output-mapping).
</ResponseField>

<ResponseField name="timeout" type="int" optional>
  Per-attempt request timeout in seconds. Defaults to `15`. Maximum `120` (values above this are rejected by the API).
</ResponseField>

<ResponseField name="rate_limit" type="int" optional>
  Maximum requests per minute. Leave empty for no limit (no throttling).
</ResponseField>

<ResponseField name="retry_enabled" type="bool" optional>
  Whether automatic retry is enabled. Defaults to `true`. See [Retry Configuration](/concepts/product/endpoint-connection-configuration#retry-configuration).
</ResponseField>

<ResponseField name="retry_max_attempts" type="int" optional>
  Maximum retry attempts (0–10). Defaults to `1`. These are retries after the first call, so N attempts means up to N+1 calls to your endpoint, and each call uses credits. `0` is only valid when retry is disabled; with retry enabled the minimum is `1`.
</ResponseField>

<ResponseField name="retry_initial_delay_ms" type="int" optional>
  Initial delay in milliseconds before first retry. Defaults to `1000`.
</ResponseField>

<ResponseField name="retry_backoff_strategy" type="string" optional>
  Backoff strategy. Valid values: `FIXED`, `EXPONENTIAL`, `LINEAR`. Defaults to `EXPONENTIAL`.
</ResponseField>

<ResponseField name="retry_max_delay_ms" type="int" optional>
  Maximum delay between retry attempts, in milliseconds. Defaults to `3000`. Capped at `60000`; values above this are rejected.
</ResponseField>

<ResponseField name="retryable_status_codes" type="list[int]" optional>
  HTTP status codes that trigger retry. Defaults to `[429, 500, 502, 503, 504]`. Each value must be a valid HTTP status code (100–599).
</ResponseField>
