# Record origin certificate details in D1

Look up a certificate by serial number and refresh its hostname and expiry record in D1.

[Use template](https://dashboard.fasthook.io/workflow/new?templateKey=origin-ca-certificate-inventory-to-d1&templateName=Record+origin+certificate+details+in+D1)

**Required accounts**

- Cloudflare Origin CA
- Cloudflare D1

## Record origin certificate details in D1

### 1. Trigger · Certificate inventory update requested

**Webhook**. Receive a JSON submission from your existing form backend at this Workflow's private webhook URL.

### 2. Action · Read the certificate from Cloudflare

**Cloudflare Origin CA**. Read the hostnames, expiration date and signed certificate for a specific serial number.

### 3. Transformation · Prepare the inventory record

**FastHook**. Run JavaScript to prepare data for the next workflow step.

### 4. Action · Insert or refresh the certificate record

**Cloudflare D1**. Run a statement with bound values, or send a batch. Each row in the results uses the column names from your query.

## Set up your workflow

1. **Prepare the inventory table** In your target D1 database run CREATE TABLE IF NOT EXISTS origin\_certificates (serial TEXT PRIMARY KEY, details TEXT NOT NULL).
2. **Choose the database** Connect the Origin CA zone and select the destination D1 database. The workflow records hostnames and dates under the full serial number.
3. **Refresh a record** POST certificate\_id as a quoted string to the private webhook. Repeat the request and confirm the row count stays the same.

## Related integrations

- [Webhook trigger](https://www.fasthook.io/docs/triggers/webhook)
- [Cloudflare Origin CA integrations](https://www.fasthook.io/apps/cloudflare-origin-ca/integrations)
- [Cloudflare D1 integrations](https://www.fasthook.io/apps/cloudflare-d1/integrations)

## Related workflow templates

- [Revoke a retired origin certificate and notify Slack](https://www.fasthook.io/templates/origin-ca-retirement-receipts-to-slack.md): Match an approved retirement to a configured certificate, revoke it and post the Cloudflare receipt to the operations channel.
- [Archive newly issued origin certificates in R2](https://www.fasthook.io/templates/origin-ca-issued-certificates-to-r2.md): Sign a CSR for a configured origin hostname and save the signed PEM in R2 under its serial number.
