Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@
"management-api/http-endpoints/delete"
]
},
{
"group": "Functions",
"pages": [
"management-api/functions/list",
"management-api/functions/get",
"management-api/functions/create",
"management-api/functions/update",
"management-api/functions/delete"
]
},
{
"group": "Sink consumers",
"pages": [
Expand Down
165 changes: 165 additions & 0 deletions docs/management-api/functions/create.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
title: "Create Function"
description: "Create a new function"
---

## Request

<CodeGroup>
```bash cURL
curl -X POST "https://api.sequinstream.com/api/functions" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "my-filter",
"description": "Filter records with value greater than 40",
"type": "filter",
"code": "def filter(action, record, changes, metadata) do\n record[\"value\"] > 40\nend"
}'
```

```javascript JavaScript
const response = await fetch('https://api.sequinstream.com/api/functions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'my-filter',
description: 'Filter records with value greater than 40',
type: 'filter',
code: `def filter(action, record, changes, metadata) do
record["value"] > 40
end`
})
});
const function = await response.json();
```
</CodeGroup>

## Parameters

<ParamField path="name" type="string" required>
Unique name for the function
</ParamField>

<ParamField path="description" type="string">
Optional description of what the function does
</ParamField>

<ParamField path="type" type="string" required>
Type of function: `filter`, `transform`, `enrichment`, `path`, or `routing`
</ParamField>

<ParamField path="code" type="string">
Function code (required for `filter`, `transform`, `enrichment`, and `routing` types)
</ParamField>

<ParamField path="path" type="string">
Path to extract (required for `path` type)
</ParamField>

<ParamField path="sink_type" type="string">
Sink type (required for `routing` type): `http_push`, `sqs`, `kafka`, etc.
</ParamField>

## Function Types

### Filter Function

```json
{
"name": "my-filter",
"description": "Filter VIP customers",
"type": "filter",
"code": "def filter(action, record, changes, metadata) do\n record[\"customer_type\"] == \"VIP\"\nend"
}
```

### Transform Function

```json
{
"name": "my-transform",
"description": "Extract ID and action",
"type": "transform",
"code": "def transform(action, record, changes, metadata) do\n %{id: record[\"id\"], action: action}\nend"
}
```

### Path Function

```json
{
"name": "my-path",
"description": "Extract record",
"type": "path",
"path": "record"
}
```

### Routing Function

```json
{
"name": "my-routing",
"description": "Route to REST API",
"type": "routing",
"sink_type": "http_push",
"code": "def route(action, record, changes, metadata) do\n %{\n method: \"POST\",\n endpoint_path: \"/api/users/#{record[\"id\"]}\"\n }\nend"
}
```

### Enrichment Function

```json
{
"name": "my-enrichment",
"description": "Enrich with customer data",
"type": "enrichment",
"code": "SELECT\n u.id,\n a.name as account_name\nFROM\n users u\nJOIN\n accounts a on u.account_id = a.id\nWHERE\n u.id = ANY($1)"
}
```

## Response

<ResponseField name="id" type="string">
Unique identifier for the function
</ResponseField>

<ResponseField name="name" type="string">
Name of the function
</ResponseField>

<ResponseField name="description" type="string">
Description of the function
</ResponseField>

<ResponseField name="type" type="string">
Type of the function
</ResponseField>

<ResponseField name="code" type="string">
Function code (for applicable types)
</ResponseField>

<ResponseField name="path" type="string">
Path (for path type functions)
</ResponseField>

<ResponseField name="sink_type" type="string">
Sink type (for routing type functions)
</ResponseField>

## Example Response

```json
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "my-filter",
"description": "Filter records with value greater than 40",
"type": "filter",
"code": "def filter(action, record, changes, metadata) do\n record[\"value\"] > 40\nend"
}
```
63 changes: 63 additions & 0 deletions docs/management-api/functions/delete.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: "Delete Function"
description: "Delete a function by ID or name"
---

## Request

You can delete a function by either its ID or name.

<CodeGroup>
```bash cURL (by ID)
curl -X DELETE "https://api.sequinstream.com/api/functions/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer YOUR_API_TOKEN"
```

```bash cURL (by name)
curl -X DELETE "https://api.sequinstream.com/api/functions/my-filter" \
-H "Authorization: Bearer YOUR_API_TOKEN"
```

```javascript JavaScript
const response = await fetch('https://api.sequinstream.com/api/functions/my-filter', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
});
const result = await response.json();
```
</CodeGroup>

## Path Parameters

<ParamField path="id_or_name" type="string" required>
Function ID (UUID) or name
</ParamField>

## Response

Returns the deleted function's ID and a confirmation flag.

<ResponseField name="id" type="string">
ID of the deleted function
</ResponseField>

<ResponseField name="deleted" type="boolean">
Always `true` for successful deletions
</ResponseField>

## Example Response

```json
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"deleted": true
}
```

## Notes

<Warning>
Deleting a function that is referenced by a sink will fail with a foreign key constraint error. Remove the function from any sinks before deleting it.
</Warning>
51 changes: 51 additions & 0 deletions docs/management-api/functions/get.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: "Get Function"
description: "Get a function by ID or name"
---

## Request

You can retrieve a function by either its ID or name.

<CodeGroup>
```bash cURL (by ID)
curl -X GET "https://api.sequinstream.com/api/functions/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer YOUR_API_TOKEN"
```

```bash cURL (by name)
curl -X GET "https://api.sequinstream.com/api/functions/my-filter" \
-H "Authorization: Bearer YOUR_API_TOKEN"
```

```javascript JavaScript
const response = await fetch('https://api.sequinstream.com/api/functions/my-filter', {
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
});
const function = await response.json();
```
</CodeGroup>

## Path Parameters

<ParamField path="id_or_name" type="string" required>
Function ID (UUID) or name
</ParamField>

## Response

Returns a function object.

## Example Response

```json
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "my-filter",
"description": "Filter records with value greater than 40",
"type": "filter",
"code": "def filter(action, record, changes, metadata) do\n record[\"value\"] > 40\nend"
}
```
53 changes: 53 additions & 0 deletions docs/management-api/functions/list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: "List Functions"
description: "List all functions for your account"
---

## Request

<CodeGroup>
```bash cURL
curl -X GET "https://api.sequinstream.com/api/functions" \
-H "Authorization: Bearer YOUR_API_TOKEN"
```

```javascript JavaScript
const response = await fetch('https://api.sequinstream.com/api/functions', {
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
});
const { data } = await response.json();
```
</CodeGroup>

## Response

Returns an array of function objects.

<ResponseField name="data" type="array">
Array of function objects
</ResponseField>

## Example Response

```json
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "my-filter",
"description": "Filter records with value greater than 40",
"type": "filter",
"code": "def filter(action, record, changes, metadata) do\n record[\"value\"] > 40\nend"
},
{
"id": "660e8400-e29b-41d4-a716-446655440001",
"name": "my-transform",
"description": "Extract ID and action",
"type": "transform",
"code": "def transform(action, record, changes, metadata) do\n %{id: record[\"id\"], action: action}\nend"
}
]
}
```
Loading
Loading