# `Electric.Shapes.Api`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/electric/shapes/api.ex#L1)

# `options`

```elixir
@type options() :: [
  stack_id: binary(),
  inspector: {module(), [term()]},
  allow_shape_deletion: boolean(),
  feature_flags: [binary()],
  keepalive_interval: integer(),
  long_poll_timeout: integer(),
  sse_timeout: integer(),
  max_age: integer(),
  stack_ready_timeout: integer(),
  stale_age: integer(),
  send_cache_headers?: boolean(),
  encoder: atom(),
  max_concurrent_requests: map()
]
```

# `shape_opts`

```elixir
@type shape_opts() :: [
  relation: {binary(), binary()},
  where: term(),
  columns: [binary()] | nil,
  params: %{optional(binary()) =&gt; binary()},
  autofill_pk_select?: boolean(),
  replica: term(),
  feature_flags: [binary()],
  storage: nil | Electric.Shapes.Shape.storage_config(),
  log_mode: term(),
  table: binary(),
  schema: binary(),
  namespace: binary()
]
```

# `t`

```elixir
@type t() :: %Electric.Shapes.Api{
  allow_shape_deletion: term(),
  configured: term(),
  encoder: term(),
  feature_flags: term(),
  inspector: term(),
  keepalive_interval: term(),
  long_poll_timeout: term(),
  max_age: term(),
  max_concurrent_requests: term(),
  send_cache_headers?: term(),
  shape: term(),
  sse_encoder: term(),
  sse_timeout: term(),
  stack_id: term(),
  stack_ready_timeout: term(),
  stale_age: term()
}
```

# `configure`

# `configure!`

# `delete_shape`

```elixir
@spec delete_shape(Electric.Shapes.Api.Request.t()) ::
  Electric.Shapes.Api.Response.t()
@spec delete_shape(Plug.Conn.t()) :: Plug.Conn.t()
```

# `delete_shape`

# `encode_error_message`

```elixir
@spec encode_error_message(t() | Electric.Shapes.Api.Request.t(), term()) :: Enum.t()
```

# `encode_message`

```elixir
@spec encode_message(Electric.Shapes.Api.Request.t(), term()) :: Enum.t()
```

# `if_not_modified`

# `load_shape_info`

```elixir
@spec load_shape_info(Electric.Shapes.Api.Request.t()) ::
  {:ok, Electric.Shapes.Api.Request.t()}
  | {:error, Electric.Shapes.Api.Response.t()}
```

Load or create the shape for a validated request, and seek to the correct offset.

Must be called with a request returned by `validate_params/2`.

# `options`

```elixir
@spec options(Plug.Conn.t()) :: Plug.Conn.t()
```

# `plug_opts`

# `predefined_shape`

```elixir
@spec predefined_shape(t(), shape_opts()) :: {:ok, t()} | {:error, term()}
```

Create a version of the given configured Api instance that is specific to the
given shape.

This allows you to provide a locked-down version of the API that ignores
shape-definition parameters such as `table`, `where` and `columns` and only
honours the shape-tailing parameters such as `offset` and `handle`.

# `schema`

# `serve_shape_log`

```elixir
@spec serve_shape_log(Electric.Shapes.Api.Request.t()) ::
  Electric.Shapes.Api.Response.t()
```

Return shape log data.

# `serve_shape_log`

# `serve_shape_response`

# `serve_shape_response`

# `serve_subset_response`

# `stack_id`

```elixir
@spec stack_id(
  t()
  | Electric.Shapes.Api.Request.t()
  | Electric.Shapes.Api.Response.t()
) :: String.t()
```

# `validate`

```elixir
@spec validate(t(), %{required(atom() | binary()) =&gt; term()}) ::
  {:ok, Electric.Shapes.Api.Request.t()}
  | {:error, Electric.Shapes.Api.Response.t()}
```

Validate the parameters for the request and load/create the shape.

This is a convenience wrapper that calls `validate_params/2` followed by
`load_shape_info/1`. Use the individual functions when you need to perform
actions (like admission control) between validation and shape creation.

# `validate_for_delete`

```elixir
@spec validate_for_delete(t(), %{required(atom() | binary()) =&gt; term()}) ::
  {:ok, Electric.Shapes.Api.Request.t()}
  | {:error, Electric.Shapes.Api.Response.t()}
```

# `validate_params`

```elixir
@spec validate_params(t(), %{required(atom() | binary()) =&gt; term()}) ::
  {:ok, Electric.Shapes.Api.Request.t()}
  | {:error, Electric.Shapes.Api.Response.t()}
```

Validate request parameters without creating or loading a shape.

Returns a validated `Request` with parsed parameters and shape definition,
but no shape handle. Call `load_shape_info/1` afterwards to create or look
up the shape.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
