Sample Controller¶
Overview¶
The Sample Controller manages sample data resources — predefined datasets that can be used during template preview and generation. It inherits the full Resource Controller endpoint set and adds endpoints for retrieving parsed sample data and filtering samples by name.
Base path: /api/samples
Authentication¶
All endpoints require the X-API-KEY header for authentication.
Inherited Endpoints¶
All endpoints documented in Resource Controller are available at /api/samples.
Sample-Specific Endpoints¶
Get Sample Data¶
GET /api/samples/{id}/data
Retrieves the parsed data records from a sample, optionally filtered through an input channel configuration.
Parameters¶
| Name | Type | In | Required | Description |
|---|---|---|---|---|
id |
integer (long) | path | Yes | Sample resource ID |
inputChannelConfigId |
integer (long) | query | No | ID of the input channel configuration to apply when reading the data |
X-API-KEY |
string | header | Yes | API authentication key |
Response¶
| Status | Description |
|---|---|
200 OK |
List of Data objects parsed from the sample |
Example response:
[
{
"id": "record-1",
"fields": {
"customerName": "Acme Corp",
"invoiceNumber": "INV-001",
"amount": 1250.00
}
},
{
"id": "record-2",
"fields": {
"customerName": "Widget Co",
"invoiceNumber": "INV-002",
"amount": 875.50
}
}
]
Code Examples¶
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
apiKey := "your-api-key"
baseURL := "https://your-comfly-instance.com"
req, _ := http.NewRequest("GET",
baseURL+"/api/samples/12/data?inputChannelConfigId=3", nil)
req.Header.Set("X-API-KEY", apiKey)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.*;
public class GetSampleData {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(
"https://your-comfly-instance.com/api/samples/12/data"
+ "?inputChannelConfigId=3"))
.header("X-API-KEY", "your-api-key")
.GET()
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Filter Samples by Name¶
GET /api/samples/filter
Returns a list of sample resources whose names match the given substring.
Parameters¶
| Name | Type | In | Required | Description |
|---|---|---|---|---|
name |
string | query | Yes | Name substring to filter by (case-insensitive) |
X-API-KEY |
string | header | Yes | API authentication key |
Response¶
| Status | Description |
|---|---|
200 OK |
List of matching SampleDto objects |
Example response:
[
{
"id": 12,
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"name": "Invoice Sample Data",
"type": "SAMPLE",
"description": "Sample records for invoice template testing"
}
]
Code Examples¶
package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
params := url.Values{"name": {"invoice"}}
req, _ := http.NewRequest("GET",
"https://your-comfly-instance.com/api/samples/filter?"+params.Encode(), nil)
req.Header.Set("X-API-KEY", "your-api-key")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.*;
public class FilterSamples {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(
"https://your-comfly-instance.com/api/samples/filter?name=invoice"))
.header("X-API-KEY", "your-api-key")
.GET()
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}