Design Parameters
The GET /file/design/parameter/{designId} endpoint retrieves the parameter structure for a specified design ID. You can check the schema for parameters needed for PDF or thumbnail generation.
Endpoint Information
- URL:
https://{workspaceId}.re-port-flow.com/v1/file/design/parameter/{designId} - Method:
GET - Authentication: Requires AppKey and SecretKey
Usage Examples
cURL
# Get latest version parameters
curl -X GET https://your-workspace-id.re-port-flow.com/v1/file/design/parameter/550e8400-e29b-41d4-a716-446655440000 \
-H "AppKey: your-app-key" \
-H "SecretKey: your-secret-key"
# Get specific version parameters
curl -X GET "https://your-workspace-id.re-port-flow.com/v1/file/design/parameter/550e8400-e29b-41d4-a716-446655440000?version=1" \
-H "AppKey: your-app-key" \
-H "SecretKey: your-secret-key"
JavaScript
async function getDesignParameters(designId, version = null) {
const url = version
? `https://${process.env.WORKSPACE_ID}.re-port-flow.com/v1/file/design/parameter/${designId}?version=${version}`
: `https://${process.env.WORKSPACE_ID}.re-port-flow.com/v1/file/design/parameter/${designId}`;
const response = await axios.get(url, {
headers: {
'AppKey': process.env.APP_KEY,
'SecretKey': process.env.SECRET_KEY
}
});
return response.data;
}
// Usage example
const schema = await getDesignParameters('550e8400-...');
console.log('Parameter schema:', schema);
Python
def get_design_parameters(design_id, version=None):
base_url = f"https://{os.getenv('WORKSPACE_ID')}.re-port-flow.com/v1"
url = f"{base_url}/file/design/parameter/{design_id}"
if version:
url += f"?version={version}"
headers = {
'AppKey': os.getenv('APP_KEY'),
'SecretKey': os.getenv('SECRET_KEY')
}
response = requests.get(url, headers=headers)
response.raise_for_status()
return response.json()
# Usage example
schema = get_design_parameters('550e8400-...')
print('Parameter schema:', schema)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
designId | string (UUID) | ✓ | Design ID (path parameter) |
version | integer | - | Version number (query parameter, defaults to latest) |
Response
Success (200 OK)
{
"customerName": "string",
"invoiceNumber": "string",
"amount": "number",
"items": [
{
"name": "string",
"price": "number",
"quantity": "number"
}
],
"issueDate": "date"
}
Field types:
| Type | Description | Example |
|---|---|---|
string | String | "John Doe" |
number | Number | 1000 |
date | Date (ISO 8601) | "2024-02-12" |
object | Nested object | { "name": "value" } |
array | Array | [{ "item": 1 }] |
Errors
404 Not Found
{
"statusCode": 404,
"message": "Design not found",
"error": "Not Found"
}
Cause: Specified design ID or version does not exist
Use Cases
Dynamic Form Generation
Generate input forms dynamically from design parameters.
async function createDynamicForm(designId) {
// Get parameter schema
const schema = await getDesignParameters(designId);
// Generate form fields from schema
const formFields = Object.entries(schema).map(([key, type]) => {
if (type === 'string') {
return `<input type="text" name="${key}" placeholder="${key}" />`;
} else if (type === 'number') {
return `<input type="number" name="${key}" placeholder="${key}" />`;
} else if (type === 'date') {
return `<input type="date" name="${key}" />`;
} else if (Array.isArray(type)) {
// Array type
return `<div id="${key}-array"><!-- Array input --></div>`;
}
});
return formFields.join('\n');
}
Validation
function validateParams(params, schema) {
const errors = [];
for (const [key, type] of Object.entries(schema)) {
if (!(key in params)) {
errors.push(`Required parameter ${key} is missing`);
continue;
}
const value = params[key];
if (type === 'string' && typeof value !== 'string') {
errors.push(`${key} must be a string`);
} else if (type === 'number' && typeof value !== 'number') {
errors.push(`${key} must be a number`);
} else if (type === 'date') {
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
errors.push(`${key} must be in ISO 8601 date format`);
}
}
}
return errors;
}
// Usage example
const schema = await getDesignParameters('550e8400-...');
const params = {
customerName: 'John Doe',
invoiceNumber: 'INV-001',
amount: 10000
};
const errors = validateParams(params, schema);
if (errors.length > 0) {
console.error('Validation errors:', errors);
}
Best Practices
1. Cache Parameter Schema
Parameter schemas don't change unless the design version changes. Cache and reuse them.
const schemaCache = new Map();
async function getDesignParametersCached(designId, version) {
const cacheKey = `${designId}:${version}`;
if (schemaCache.has(cacheKey)) {
return schemaCache.get(cacheKey);
}
const schema = await getDesignParameters(designId, version);
schemaCache.set(cacheKey, schema);
return schema;
}
2. Validate Before PDF Generation
Get parameter schema in advance and validate to detect errors early.
async function generatePDFSafely(params) {
// 1. Get parameter schema
const schema = await getDesignParameters(params.designId, params.version);
// 2. Validate
const errors = validateParams(params.data, schema);
if (errors.length > 0) {
throw new Error(`Parameter errors: ${errors.join(', ')}`);
}
// 3. Generate PDF
return await generatePDF(params);
}
Next Steps
- Sync Single PDF Generation - Generate PDF using parameters
- Error Handling - Handle validation errors