Go
Call the Create a Fillable PDF API from Go.
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
var body bytes.Buffer
w := multipart.NewWriter(&body)
f, _ := os.Open("applicant.pdf")
defer f.Close()
part, _ := w.CreateFormFile("file", "applicant.pdf")
io.Copy(part, f)
w.WriteField("detect", "fields")
w.Close()
req, _ := http.NewRequest("POST", "https://api.createafillablepdf.com/v1/convert", &body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("CAFP_KEY"))
req.Header.Set("Content-Type", w.FormDataContentType())
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))
}
Fill with POST /v1/fill (JSON body { "conversion_id": "...", "values": { ... } }).