Skip to content

Commit ae550fc

Browse files
committed
added POST /api/v1/templates/pdf endpoint to upload the pdf first before template registry
1 parent 1154797 commit ae550fc

2 files changed

Lines changed: 102 additions & 0 deletions

File tree

contracts/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ paths:
8686
$ref: "path/templates.yaml#/template_by_id"
8787
/api/v1/templates/{template_id}/fields:
8888
$ref: "path/templates.yaml#/template_fields"
89+
/api/v1/templates/pdf:
90+
$ref: "path/templates.yaml#/templates_pdf"
8991

9092
# ── Layer 7: System ────────────────────────────────────────────
9193
/api/v1/health:

contracts/path/templates.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# POST /api/v1/templates
55
# PUT /api/v1/templates/{template_id}
66
# GET /api/v1/templates/{template_id}/fields
7+
# POST /api/v1/templates/pdf
78

89
templates:
910
get:
@@ -304,3 +305,102 @@ template_fields:
304305
application/json:
305306
schema:
306307
$ref: "../schemas/common.yaml#/ErrorResponse"
308+
309+
templates_pdf:
310+
post:
311+
operationId: uploadTemplatePdf
312+
summary: Upload a blank PDF for a template before defining its fields
313+
description: |
314+
Uploads the blank agency PDF that a template's field coordinates will be
315+
written onto, and returns a `pdf_template_ref` plus the page geometry.
316+
317+
This is the first step of the template-authoring flow. The visual editor
318+
renders the returned pages, the user draws a box per field, and the box
319+
coordinates become each field's `layout`. The resulting `pdf_template_ref`
320+
is then sent in the `POST /api/v1/templates` body. Upload precedes create
321+
because the layout coordinates only have meaning relative to this PDF.
322+
323+
Page dimensions are returned in PDF points (1/72 inch, origin bottom-left)
324+
so the editor can map canvas positions to the same coordinate system the
325+
`layout` fields use.
326+
tags:
327+
- templates
328+
requestBody:
329+
required: true
330+
content:
331+
multipart/form-data:
332+
schema:
333+
type: object
334+
required:
335+
- pdf_file
336+
properties:
337+
pdf_file:
338+
type: string
339+
format: binary
340+
description: Blank fillable or flat PDF form. Max 50MB.
341+
responses:
342+
"201":
343+
description: PDF stored and ready to be referenced by a template
344+
content:
345+
application/json:
346+
schema:
347+
type: object
348+
required:
349+
- pdf_template_ref
350+
- original_filename
351+
- page_count
352+
- pages
353+
properties:
354+
pdf_template_ref:
355+
type: string
356+
description: Opaque reference to the stored PDF, passed back in
357+
the template body as pdf_template_ref
358+
original_filename:
359+
type: string
360+
page_count:
361+
type: integer
362+
pages:
363+
type: array
364+
description: Per-page geometry in PDF points, index 0 = first page
365+
items:
366+
type: object
367+
required:
368+
- page
369+
- width
370+
- height
371+
properties:
372+
page:
373+
type: integer
374+
width:
375+
type: number
376+
height:
377+
type: number
378+
example:
379+
pdf_template_ref: "templates/uploads/550e8400-e29b-41d4-a716-446655440080.pdf"
380+
original_filename: "texas_sfm_incident.pdf"
381+
page_count: 2
382+
pages:
383+
- page: 0
384+
width: 612.0
385+
height: 792.0
386+
- page: 1
387+
width: 612.0
388+
height: 792.0
389+
"400":
390+
description: Missing file or malformed multipart request
391+
content:
392+
application/json:
393+
schema:
394+
$ref: "../schemas/common.yaml#/ErrorResponse"
395+
"413":
396+
description: PDF exceeds the maximum allowed size
397+
content:
398+
application/json:
399+
schema:
400+
$ref: "../schemas/common.yaml#/ErrorResponse"
401+
"415":
402+
description: Uploaded file is not a valid PDF
403+
content:
404+
application/json:
405+
schema:
406+
$ref: "../schemas/common.yaml#/ErrorResponse"

0 commit comments

Comments
 (0)