background image

Procedures

Store a sequence of queries under a name and run it in one call, with parameters.

Background and examples: Custom queries and procedures

List procedures

GET /v1/procedures

Lists the procedures of a project.

Parameters

project uuid query required

The GUID of the project.

Responses

  • 200 Success

Request

curl -X GET 'https://api.stellards.io/v1/procedures?project=PROJECT_ID' \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response 200

{
  "messages": [],
  "isSuccess": true,
  "data": [
    {
      "name": "Customers",
      "description": "Everyone who placed an order",
      "version": 1,
      "createdAt": "2026-11-02T09:30:00Z",
      "updatedAt": "2026-11-02T09:30:00Z",
      "parameters": [
        {
          "name": "Customers",
          "type": "NVarChar(255)",
          "required": true,
          "defaultValue": null
        }
      ],
      "steps": [
        {
          "name": "Customers",
          "sql": "select id, Total from Orders where CustomerId = @customer"
        }
      ],
      "problems": []
    }
  ]
}

Create a procedure

POST /v1/procedures

Creates a procedure. Every step is compiled first; the response lists every problem.

Parameters

project uuid query required

The GUID of the project.

Request body application/json

The procedure.

name string required

The procedure's name, unique in the project; you call it by this name.

description string

A description for your own reference.

parameters object[]

The parameters callers pass, each with a name, a SQL type, whether it is required and an optional default value.

steps object[]

The SELECT statements to run in order, each with a name; the result has one entry per step.

version integer

On a replace: the version you edited, so you are told when someone saved a newer one.

Responses

  • 201 The procedure was created.
  • 400 The procedure isn't valid, the name is taken or the tier's limit is reached.
  • 403 The caller can't create tables, or the tier doesn't include procedures.

Request

curl -X POST 'https://api.stellards.io/v1/procedures?project=PROJECT_ID' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "OrdersOfCustomer",
    "parameters": [
      {
        "name": "customer",
        "type": "bigint",
        "required": true
      }
    ],
    "steps": [
      {
        "name": "orders",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ]
  }'

Response 201

{
  "messages": [],
  "isSuccess": true,
  "data": {
    "name": "Customers",
    "description": "Everyone who placed an order",
    "version": 1,
    "createdAt": "2026-11-02T09:30:00Z",
    "updatedAt": "2026-11-02T09:30:00Z",
    "parameters": [
      {
        "name": "Customers",
        "type": "NVarChar(255)",
        "required": true,
        "defaultValue": null
      }
    ],
    "steps": [
      {
        "name": "Customers",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ],
    "problems": []
  }
}

Get a procedure

GET /v1/procedures/{name}

Gets one procedure.

Parameters

project uuid query required

The GUID of the project.

name string path required

The name of the procedure.

Responses

  • 200 Success
  • 404 Not Found

Request

curl -X GET 'https://api.stellards.io/v1/procedures/PROCEDURE_NAME?project=PROJECT_ID' \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response 200

{
  "messages": [],
  "isSuccess": true,
  "data": {
    "name": "Customers",
    "description": "Everyone who placed an order",
    "version": 1,
    "createdAt": "2026-11-02T09:30:00Z",
    "updatedAt": "2026-11-02T09:30:00Z",
    "parameters": [
      {
        "name": "Customers",
        "type": "NVarChar(255)",
        "required": true,
        "defaultValue": null
      }
    ],
    "steps": [
      {
        "name": "Customers",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ],
    "problems": []
  }
}

Replace a procedure

PUT /v1/procedures/{name}

Replaces a procedure and increases its version.

Parameters

project uuid query required

The GUID of the project.

name string path required

The current name of the procedure.

Request body application/json

The new procedure. Pass the version you edited to be told when someone saved a newer one.

name string required

The procedure's name, unique in the project; you call it by this name.

description string

A description for your own reference.

parameters object[]

The parameters callers pass, each with a name, a SQL type, whether it is required and an optional default value.

steps object[]

The SELECT statements to run in order, each with a name; the result has one entry per step.

version integer

On a replace: the version you edited, so you are told when someone saved a newer one.

Responses

  • 200 Success
  • 400 Bad Request
  • 409 Someone saved a newer version after the one in the request.

Request

curl -X PUT 'https://api.stellards.io/v1/procedures/PROCEDURE_NAME?project=PROJECT_ID' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "OrdersOfCustomer",
    "description": "Every order of one customer",
    "parameters": [
      {
        "name": "customer",
        "type": "bigint",
        "required": true
      }
    ],
    "steps": [
      {
        "name": "orders",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ],
    "version": 1
  }'

Response 200

{
  "messages": [],
  "isSuccess": true,
  "data": {
    "name": "Customers",
    "description": "Everyone who placed an order",
    "version": 1,
    "createdAt": "2026-11-02T09:30:00Z",
    "updatedAt": "2026-11-02T09:30:00Z",
    "parameters": [
      {
        "name": "Customers",
        "type": "NVarChar(255)",
        "required": true,
        "defaultValue": null
      }
    ],
    "steps": [
      {
        "name": "Customers",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ],
    "problems": []
  }
}

Delete a procedure

DELETE /v1/procedures/{name}

Deletes a procedure.

Parameters

project uuid query required

The GUID of the project.

name string path required

The name of the procedure.

Responses

  • 200 Success
  • 404 Not Found

Request

curl -X DELETE 'https://api.stellards.io/v1/procedures/PROCEDURE_NAME?project=PROJECT_ID' \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response 200

{
  "messages": [],
  "isSuccess": true
}

Run a procedure

POST /v1/procedures/{name}/execute

Runs a procedure and returns one result per step.

Parameters

project uuid query required

The GUID of the project.

name string path required

The name of the procedure.

Request body application/json

The parameter values, for example { "parameters": { "customer": 42 } }.

parameters object

The parameter values, by name.

Responses

  • 200 Success
  • 400 A parameter is missing or has the wrong type, a step no longer compiles, or a step failed or took too long.
  • 403 The tier doesn't include custom queries or the caller can't read a table a step uses.
  • 429 Too many custom queries are running for the project.

Request

curl -X POST 'https://api.stellards.io/v1/procedures/PROCEDURE_NAME/execute?project=PROJECT_ID' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "parameters": {
      "customer": 42
    }
  }'

Response 200

{
  "messages": [],
  "isSuccess": true,
  "data": {
    "name": "Customers",
    "version": 1,
    "results": [
      {
        "columns": [
          {
            "name": null,
            "type": null
          }
        ],
        "rows": [
          {}
        ],
        "count": 1,
        "truncated": false,
        "durationMs": 38,
        "step": "orders"
      }
    ],
    "durationMs": 38
  }
}

List procedures Path-style route

GET /project/{project}/procedures

Lists the procedures of a project.

Parameters

project uuid path required

The GUID of the project. Provided as a route parameter.

Responses

  • 200 Success

Request

curl -X GET 'https://api.stellards.io/project/PROJECT_ID/procedures' \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response 200

{
  "messages": [],
  "isSuccess": true,
  "data": [
    {
      "name": "Customers",
      "description": "Everyone who placed an order",
      "version": 1,
      "createdAt": "2026-11-02T09:30:00Z",
      "updatedAt": "2026-11-02T09:30:00Z",
      "parameters": [
        {
          "name": "Customers",
          "type": "NVarChar(255)",
          "required": true,
          "defaultValue": null
        }
      ],
      "steps": [
        {
          "name": "Customers",
          "sql": "select id, Total from Orders where CustomerId = @customer"
        }
      ],
      "problems": []
    }
  ]
}

Create a procedure Path-style route

POST /project/{project}/procedures

Creates a procedure. Every step is compiled first; the response lists every problem.

Parameters

project uuid path required

The GUID of the project. Provided as a route parameter.

Request body application/json

The procedure.

name string required

The procedure's name, unique in the project; you call it by this name.

description string

A description for your own reference.

parameters object[]

The parameters callers pass, each with a name, a SQL type, whether it is required and an optional default value.

steps object[]

The SELECT statements to run in order, each with a name; the result has one entry per step.

version integer

On a replace: the version you edited, so you are told when someone saved a newer one.

Responses

  • 201 The procedure was created.
  • 400 The procedure isn't valid, the name is taken or the tier's limit is reached.
  • 403 The caller can't create tables, or the tier doesn't include procedures.

Request

curl -X POST 'https://api.stellards.io/project/PROJECT_ID/procedures' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "OrdersOfCustomer",
    "parameters": [
      {
        "name": "customer",
        "type": "bigint",
        "required": true
      }
    ],
    "steps": [
      {
        "name": "orders",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ]
  }'

Response 201

{
  "messages": [],
  "isSuccess": true,
  "data": {
    "name": "Customers",
    "description": "Everyone who placed an order",
    "version": 1,
    "createdAt": "2026-11-02T09:30:00Z",
    "updatedAt": "2026-11-02T09:30:00Z",
    "parameters": [
      {
        "name": "Customers",
        "type": "NVarChar(255)",
        "required": true,
        "defaultValue": null
      }
    ],
    "steps": [
      {
        "name": "Customers",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ],
    "problems": []
  }
}

Get a procedure Path-style route

GET /project/{project}/procedures/{name}

Gets one procedure.

Parameters

project uuid path required

The GUID of the project. Provided as a route parameter.

name string path required

The name of the procedure.

Responses

  • 200 Success
  • 404 Not Found

Request

curl -X GET 'https://api.stellards.io/project/PROJECT_ID/procedures/PROCEDURE_NAME' \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response 200

{
  "messages": [],
  "isSuccess": true,
  "data": {
    "name": "Customers",
    "description": "Everyone who placed an order",
    "version": 1,
    "createdAt": "2026-11-02T09:30:00Z",
    "updatedAt": "2026-11-02T09:30:00Z",
    "parameters": [
      {
        "name": "Customers",
        "type": "NVarChar(255)",
        "required": true,
        "defaultValue": null
      }
    ],
    "steps": [
      {
        "name": "Customers",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ],
    "problems": []
  }
}

Replace a procedure Path-style route

PUT /project/{project}/procedures/{name}

Replaces a procedure and increases its version.

Parameters

project uuid path required

The GUID of the project. Provided as a route parameter.

name string path required

The current name of the procedure.

Request body application/json

The new procedure. Pass the version you edited to be told when someone saved a newer one.

name string required

The procedure's name, unique in the project; you call it by this name.

description string

A description for your own reference.

parameters object[]

The parameters callers pass, each with a name, a SQL type, whether it is required and an optional default value.

steps object[]

The SELECT statements to run in order, each with a name; the result has one entry per step.

version integer

On a replace: the version you edited, so you are told when someone saved a newer one.

Responses

  • 200 Success
  • 400 Bad Request
  • 409 Someone saved a newer version after the one in the request.

Request

curl -X PUT 'https://api.stellards.io/project/PROJECT_ID/procedures/PROCEDURE_NAME' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "OrdersOfCustomer",
    "description": "Every order of one customer",
    "parameters": [
      {
        "name": "customer",
        "type": "bigint",
        "required": true
      }
    ],
    "steps": [
      {
        "name": "orders",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ],
    "version": 1
  }'

Response 200

{
  "messages": [],
  "isSuccess": true,
  "data": {
    "name": "Customers",
    "description": "Everyone who placed an order",
    "version": 1,
    "createdAt": "2026-11-02T09:30:00Z",
    "updatedAt": "2026-11-02T09:30:00Z",
    "parameters": [
      {
        "name": "Customers",
        "type": "NVarChar(255)",
        "required": true,
        "defaultValue": null
      }
    ],
    "steps": [
      {
        "name": "Customers",
        "sql": "select id, Total from Orders where CustomerId = @customer"
      }
    ],
    "problems": []
  }
}

Delete a procedure Path-style route

DELETE /project/{project}/procedures/{name}

Deletes a procedure.

Parameters

project uuid path required

The GUID of the project. Provided as a route parameter.

name string path required

The name of the procedure.

Responses

  • 200 Success
  • 404 Not Found

Request

curl -X DELETE 'https://api.stellards.io/project/PROJECT_ID/procedures/PROCEDURE_NAME' \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response 200

{
  "messages": [],
  "isSuccess": true
}

Run a procedure Path-style route

POST /project/{project}/procedures/{name}/execute

Runs a procedure and returns one result per step.

Parameters

project uuid path required

The GUID of the project. Provided as a route parameter.

name string path required

The name of the procedure.

Request body application/json

The parameter values, for example { "parameters": { "customer": 42 } }.

parameters object

The parameter values, by name.

Responses

  • 200 Success
  • 400 A parameter is missing or has the wrong type, a step no longer compiles, or a step failed or took too long.
  • 403 The tier doesn't include custom queries or the caller can't read a table a step uses.
  • 429 Too many custom queries are running for the project.

Request

curl -X POST 'https://api.stellards.io/project/PROJECT_ID/procedures/PROCEDURE_NAME/execute' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "parameters": {
      "customer": 42
    }
  }'

Response 200

{
  "messages": [],
  "isSuccess": true,
  "data": {
    "name": "Customers",
    "version": 1,
    "results": [
      {
        "columns": [
          {
            "name": null,
            "type": null
          }
        ],
        "rows": [
          {}
        ],
        "count": 1,
        "truncated": false,
        "durationMs": 38,
        "step": "orders"
      }
    ],
    "durationMs": 38
  }
}