@quiltdata/benchling-webhook 0.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md ADDED
@@ -0,0 +1,226 @@
1
+ # Benchling Webhook Integration - Complete Guide
2
+
3
+ Complete deployment and operational guide for the Benchling webhook integration with Quilt.
4
+
5
+ ## Architecture Overview
6
+
7
+ This AWS CDK application deploys a highly available, auto-scaling webhook processor using:
8
+
9
+ - **Amazon API Gateway** → Routes HTTPS webhooks with IP-based access control
10
+ - **Application Load Balancer (ALB)** → Distributes traffic across container instances
11
+ - **AWS Fargate on Amazon ECS** → Runs containerized webhook processor (auto-scales 2-10 tasks)
12
+ - **Amazon S3** → Stores webhook payloads and package data
13
+ - **Amazon SQS** → Queues package creation requests for Quilt
14
+ - **AWS Secrets Manager** → Securely stores Benchling OAuth credentials
15
+ - **Amazon CloudWatch** → Provides centralized logging and monitoring
16
+ - **AWS IAM** → Enforces least-privilege access controls
17
+
18
+ **Request Flow:** Benchling → API Gateway → ALB → Fargate (Flask app) → S3 + SQS
19
+
20
+ ### Code Organization
21
+
22
+ - **Infrastructure (CDK)**: `bin/` and `lib/` contain TypeScript CDK code for AWS deployment
23
+ - `lib/benchling-webhook-stack.ts` - Main stack orchestrating all components
24
+ - `lib/fargate-service.ts` - ECS Fargate service running Flask in Docker
25
+ - `lib/alb-api-gateway.ts` - API Gateway with HTTP integration to ALB
26
+ - `lib/ecr-repository.ts` - Docker image repository
27
+ - **Application (Python)**: `docker/` contains Flask webhook processor
28
+ - See [docker/README.md](docker/README.md) for application development
29
+
30
+ ## Prerequisites
31
+
32
+ - **AWS Account** with appropriate IAM permissions
33
+ - **AWS CLI** v2.x configured with credentials
34
+ - **Node.js** >= 18.0.0
35
+ - **Docker** for container builds
36
+ - **Quilt Stack** deployed with S3 bucket and SQS queue configured
37
+ - **Benchling Account** with app creation permissions
38
+
39
+ ## Installation
40
+
41
+ ### 1. Clone and Install
42
+
43
+ ```bash
44
+ git clone https://github.com/quiltdata/benchling-webhook.git
45
+ cd benchling-webhook
46
+ npm install
47
+ ```
48
+
49
+ ### 2. Configure Environment
50
+
51
+ #### Option A: Auto-infer from Quilt Catalog (Recommended)
52
+
53
+ If you have an existing Quilt deployment, you can automatically infer most configuration values:
54
+
55
+ ```bash
56
+ # Infer config from your Quilt catalog
57
+ npm run get-env -- https://quilt-catalog.yourcompany.com --write
58
+
59
+ # Review the generated env.inferred file
60
+ cat env.inferred
61
+
62
+ # Copy to .env and fill in Benchling credentials
63
+ cp env.inferred .env
64
+ # Then edit .env to add your Benchling-specific values
65
+ ```
66
+
67
+ The script will:
68
+
69
+ - Fetch `config.json` from your Quilt catalog
70
+ - Query AWS CloudFormation to find your Quilt stack
71
+ - Extract bucket names, queue names, region, and account ID
72
+ - Generate a `.env.inferred` file with pre-filled AWS/Quilt configuration
73
+
74
+ **Note:** You'll still need to manually add Benchling credentials (tenant, client ID, client secret, etc.).
75
+
76
+ #### Option B: Manual Configuration
77
+
78
+ ```bash
79
+ cp env.template .env
80
+ ```
81
+
82
+ Edit `.env` with your configuration:
83
+
84
+ **Required Variables** (you must provide these):
85
+
86
+ | Variable | Description |
87
+ |----------|-------------|
88
+ | `QUILT_CATALOG` | Quilt catalog URL (e.g., `quilt-catalog.yourcompany.com`) |
89
+ | `QUILT_USER_BUCKET` | Your S3 bucket for Benchling exports |
90
+ | `BENCHLING_TENANT` | Benchling subdomain (e.g., `myorg` from `myorg.benchling.com`) |
91
+ | `BENCHLING_CLIENT_ID` | OAuth client ID from Benchling app |
92
+ | `BENCHLING_CLIENT_SECRET` | OAuth client secret from Benchling app |
93
+ | `BENCHLING_APP_DEFINITION_ID` | App definition ID for webhook verification |
94
+
95
+ **Auto-Inferred Variables** (automatically determined from your Quilt catalog):
96
+
97
+ | Variable | How It's Inferred |
98
+ |----------|-------------------|
99
+ | `CDK_DEFAULT_ACCOUNT` | From AWS STS (your current account) |
100
+ | `CDK_DEFAULT_REGION` | From catalog config.json |
101
+ | `QUEUE_NAME` | From Quilt stack outputs |
102
+ | `SQS_QUEUE_URL` | From Quilt stack outputs |
103
+ | `QUILT_DATABASE` | From Quilt stack outputs |
104
+
105
+ **Optional Variables** (have sensible defaults):
106
+
107
+ | Variable | Default | Description |
108
+ |----------|---------|-------------|
109
+ | `PKG_PREFIX` | `benchling` | Quilt package name prefix |
110
+ | `PKG_KEY` | `experiment_id` | Metadata key for linking entries to packages |
111
+ | `LOG_LEVEL` | `INFO` | Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) |
112
+ | `ENABLE_WEBHOOK_VERIFICATION` | `true` | Verify webhook signatures |
113
+ | `WEBHOOK_ALLOW_LIST` | (empty) | Comma-separated IP allowlist |
114
+ | `ECR_REPOSITORY_NAME` | `quiltdata/benchling` | Custom ECR repo name |
115
+
116
+ See [doc/PARAMETERS.md](doc/PARAMETERS.md) for complete reference.
117
+
118
+ ### 3. Deploy Infrastructure
119
+
120
+ ```bash
121
+ # Bootstrap CDK (first time only)
122
+ source .env
123
+ npx cdk bootstrap aws://$CDK_DEFAULT_ACCOUNT/$CDK_DEFAULT_REGION
124
+
125
+ # Deploy stack
126
+ npm run deploy
127
+ ```
128
+
129
+ The webhook URL will be saved to `.env.deploy`:
130
+
131
+ ```bash
132
+ WEBHOOK_ENDPOINT=https://abc123.execute-api.us-east-1.amazonaws.com/prod
133
+ ```
134
+
135
+ ## Post-Deployment Configuration
136
+
137
+ ### Configure Benchling App
138
+
139
+ 1. **Create App**: Benchling → Developer Console → Apps → Create app → From manifest
140
+ 2. **Upload Manifest**: Use `app-manifest.yaml` from this repository
141
+ 3. **Set Credentials**: Create Client Secret → Copy ID and Secret to `.env`
142
+ 4. **Configure Webhook**: Overview → Webhook URL → Paste URL from `.env.deploy`
143
+ 5. **Install App**: Version History → Install → Activate
144
+ 6. **Grant Permissions**: Tenant Admin → Organizations → Apps → Add app → Set role to Admin
145
+
146
+ ### Verify Deployment
147
+
148
+ ```bash
149
+ # Health check
150
+ source .env.deploy
151
+ curl $WEBHOOK_ENDPOINT/health
152
+
153
+ # Monitor logs
154
+ aws logs tail /ecs/benchling-webhook --follow
155
+ ```
156
+
157
+ ## Usage
158
+
159
+ 1. **Create Entry** in Benchling notebook
160
+ 2. **Insert Canvas** → Select "Quilt Integration"
161
+ 3. **Create Package** → Generates versioned Quilt package
162
+ 4. **Add Files** → Attach experimental data
163
+ 5. **Update Package** → Creates new version with attachments
164
+
165
+ ## Development
166
+
167
+ ### Common Commands
168
+
169
+ **Development:**
170
+ - `npm run build` - Compile TypeScript
171
+ - `npm run test` - Run Jest tests
172
+ - `npm run lint` - Apply ESLint
173
+
174
+ **Deployment:**
175
+ - `npm run deploy` - Test + deploy (outputs to `.env.deploy`)
176
+ - `npm run docker-push` - Build and push Docker images
177
+ - `npm run docker-check` - Validate Docker images
178
+ - `npm run release` - Create production release
179
+
180
+ **Python App:**
181
+ - See [docker/README.md](docker/README.md) or run `make help` in docker/ directory
182
+
183
+ ### Coding Style
184
+
185
+ - **TypeScript**: 4-space indent, double quotes, trailing commas, required semicolons
186
+ - **Types**: Avoid `any` in production; explicit return types on exports
187
+ - **Organization**: Separate CDK constructs in `lib/`; application code in `docker/`
188
+
189
+ ### Commits & PRs
190
+
191
+ - Use Conventional Commits: `type(scope): summary`
192
+ - Keep commits focused; update `package-lock.json` when needed
193
+ - Include test results and deployment considerations in PRs
194
+
195
+ ## Security Best Practices
196
+
197
+ - OAuth credentials stored in AWS Secrets Manager
198
+ - IP-based access control via API Gateway resource policies
199
+ - Container images scanned for vulnerabilities via Amazon ECR
200
+ - IAM roles follow least-privilege principle
201
+ - All traffic encrypted in transit (TLS 1.2+)
202
+ - CloudWatch logs encrypted at rest
203
+
204
+ ## Monitoring & Troubleshooting
205
+
206
+ ### Monitoring
207
+
208
+ - **CloudWatch Logs**: `/ecs/benchling-webhook`
209
+ - **ECS Task Metrics**: CPU, memory, task count
210
+ - **API Gateway Metrics**: Request count, latency, 4XX/5XX errors
211
+ - **ALB Target Health**: Monitor unhealthy targets
212
+
213
+ ### Health Endpoints
214
+
215
+ - `/health` - General health check
216
+ - `/health/ready` - Readiness probe
217
+
218
+ ### Debugging
219
+
220
+ - **Deployment**: Check `.env.deploy` for outputs
221
+ - **Logs**: `npm run logs` or `aws logs tail /ecs/benchling-webhook --follow`
222
+ - **Events**: `npm run event` to send test events
223
+
224
+ ## License
225
+
226
+ Apache-2.0 - See [LICENSE](LICENSE) file for details
package/CHANGELOG.md ADDED
@@ -0,0 +1,91 @@
1
+ <!-- markdownlint-disable MD024 -->
2
+ # Changelog
3
+
4
+ All notable changes to this project will be documented in this file.
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.4.13] - 2025-10-28
9
+
10
+ ### Changed
11
+
12
+ - **Simplified configuration**: Auto-infer AWS and Quilt config from catalog at deployment time
13
+ - **Reduced required .env variables**: From 20+ to just 6 (catalog URL, user bucket, 4 Benchling credentials)
14
+ - **Renamed `BUCKET_NAME` → `QUILT_USER_BUCKET`**: Clearer distinction between user data bucket and Quilt system buckets
15
+ - **Added CDK bootstrap validation**: Fails fast with helpful error if account/region not bootstrapped
16
+ - **Made LOG_LEVEL configurable**: Override default INFO level for production debugging
17
+
18
+ ### Removed
19
+
20
+ - Unused environment variables: `BENCHLING_API_KEY`, `PKG_BUCKET_ONLY`, `PREFIX`, `STAGE`, `FLASK_ENV`
21
+
22
+ ### Fixed
23
+
24
+ - Module import issue: CLI argument parsing now only runs when executed directly, not on import
25
+
26
+ ## [0.4.12] - 2025-10-27
27
+
28
+ ### Added
29
+
30
+ - Dev release workflow with timestamped pre-release tags for testing CI/CD pipeline
31
+
32
+ ### Changed
33
+
34
+ - Refactored release script to separate version bumping from tag creation
35
+ - version.js now outputs just the version number when called with no arguments
36
+
37
+ ## [0.4.11] - 2025-10-27
38
+
39
+ ### Added
40
+
41
+ - Version synchronization test to ensure package.json, docker/pyproject.toml, and docker/app-manifest.yaml remain in sync
42
+ - app-manifest.yaml now published as GitHub release asset for Benchling App installations
43
+
44
+ ### Fixed
45
+
46
+ - Version bump script (bin/version.js) now updates all three version files instead of just package.json
47
+ - `docker-validate` target now validates ECR repository is publicly accessible without authentication
48
+ - `docker-validate` reads Docker image URI from `cdk-outputs.json` instead of requiring version parameter
49
+ - `docker-validate` will fail if repository requires authentication, ensuring public access is maintained
50
+
51
+ ## [0.4.10] - 2025-10-27
52
+
53
+ ### Added
54
+
55
+ - Canvas error notification section to display warnings and errors to users
56
+ - Athena permissions (StartQueryExecution, GetQueryExecution, GetQueryResults) to ECS task role
57
+ - Glue Data Catalog permissions for Athena queries
58
+ - S3 permissions for Athena query results bucket
59
+ - Test event file for Athena access denied scenario
60
+
61
+ ### Fixed
62
+
63
+ - Canvas now displays error notifications instead of failing silently when PackageQuery encounters AWS permission issues
64
+ - Improved error messages for Athena AccessDeniedException with actionable guidance
65
+
66
+ ## [0.4.9] - 2025-10-27
67
+
68
+ ### Added
69
+
70
+ - Integrated release workflow into CI pipeline for automated GitHub releases, Docker image publishing, and NPM package publishing
71
+ - Support for both production and pre-release (dev) versions
72
+
73
+ ### Changed
74
+
75
+ - Updated Python to 3.14 in CI workflows
76
+ - Updated aws-actions/configure-aws-credentials to v5
77
+ - Updated actions/setup-python to v6
78
+ - Streamlined release process with automated tagging and publishing
79
+
80
+ ## [0.4.8] - 2025-10-27
81
+
82
+ ### Changed
83
+
84
+ - **Infrastructure Migration** - Migrated from Lambda to Docker/Fargate for improved scalability and resource management
85
+ - **Improved Deployment** - Streamlined Docker-based deployment workflow with health checks and automated verification
86
+ - **Enhanced Testing** - Added comprehensive test commands for local development and CI/CD workflows
87
+
88
+ ### Fixed
89
+
90
+ - Resolved CloudFormation deployment conflicts during stack updates
91
+ - Ensured ECR repository exists before Docker push in CI
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,77 @@
1
+ # **Connecting a Webhook to Benchling via an App**
2
+
3
+ This guide walks you through integrating an **existing webhook** with Benchling by creating a **Benchling App** and subscribing to events.
4
+
5
+ ---
6
+
7
+ ## **1. Prerequisites**
8
+
9
+ Before proceeding, ensure you have:
10
+
11
+ - **Benchling Tenant Admin Access**: Permissions to create and manage apps.
12
+ - **A Public HTTPS Endpoint**: Your webhook URL that can receive POST requests.
13
+ - **API Credentials** (if required for authentication).
14
+
15
+ ---
16
+
17
+ ## **2. Creating a Benchling App**
18
+
19
+ Benchling requires an **app** to manage webhook subscriptions. Follow these steps to create one.
20
+
21
+ ### **Step 1: Access the Developer Console**
22
+
23
+ 1. **Log in to Benchling**.
24
+ 2. **Navigate to the Developer Console**:
25
+ - Click on your **profile icon** (lower-left corner).
26
+ - Select **"Feature Settings"**.
27
+ - Click on **"Developer Console"**.
28
+
29
+ ### **Step 2: Create a New App**
30
+
31
+ 1. In the **"Apps"** section, click **"Create app"**.
32
+ 2. Choose **"From scratch"**.
33
+ 3. Provide the following details:
34
+ - **Name**: A short label (e.b., "entry-webhook").
35
+ - **Description**: A brief summary of the app's purpose.
36
+ 4. Leave it as Private, or make Public.
37
+ 5. Click **"Create"**.
38
+
39
+ ---
40
+
41
+ ## **3. Configuring the Webhook Subscription**
42
+
43
+ Now, configure the app to send data to your webhook.
44
+
45
+ ### **Step 1: Define Event Subscriptions**
46
+
47
+ 1. In the app's settings, find "Webhook URL" (under Overview -> Global Information).
48
+ 2. Click the edit icon
49
+ 3. Paste in your webhook URL.
50
+ 4. Click checkmark to save.
51
+
52
+ NOTE: Enter the top-level endpoint; Benchling will send to the appropriate
53
+ path underneath that:
54
+
55
+ - assayRun: /event
56
+ - configuration: /lifecycle
57
+ - canvas: /canvas
58
+ - entry: /event
59
+ - request: /event
60
+ - workflow: /event
61
+
62
+ ### **Step 2: Webhook Testing**
63
+
64
+ 1. Go to the **"Webhook Testing"** tab.
65
+ 2. Under "**Preview**", select one of the "/event" options.
66
+ 3. Click **"Send Test"**.
67
+ 4. Confirm that the "**Test**" tab shows "Success"
68
+ 5. Verify that a package was properly created.
69
+
70
+ ### **Step 3: Add App To Your Tenant**
71
+
72
+ 1. Go back to Home (the Benchling jellyfish logo in the upper right).
73
+ 2. Go to the Tenant Admin Console (from your profile icon).
74
+ 3. Select your organization.
75
+ 4. Select Apps under your organization (NOT from your Tenant)
76
+
77
+ ---
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Benchling Webhook Integration for Quilt
2
+
3
+ Connects Benchling lab notebook entries to Quilt data packages via webhooks.
4
+
5
+ ## Quick Install
6
+
7
+ **Prerequisites:** AWS account, Node.js 18+, Docker, existing Quilt deployment
8
+
9
+ ```bash
10
+ # 1. Clone and install
11
+ git clone https://github.com/quiltdata/benchling-webhook.git
12
+ cd benchling-webhook
13
+ npm install
14
+
15
+ # 2. Configure minimal .env
16
+ cp env.template .env
17
+ # Edit .env to set:
18
+ # - QUILT_CATALOG=quilt-catalog.yourcompany.com
19
+ # - QUILT_USER_BUCKET=your-data-bucket
20
+ # - Benchling credentials (5 values)
21
+ # Everything else is auto-inferred at deploy time!
22
+
23
+ # 3. Deploy
24
+ source .env
25
+ npx cdk bootstrap aws://$CDK_DEFAULT_ACCOUNT/$CDK_DEFAULT_REGION # first time only
26
+ npm run deploy
27
+
28
+ # 4. Configure Benchling app
29
+ # - Create app from app-manifest.yaml
30
+ # - Set webhook URL from .env.deploy
31
+ # - Install and activate
32
+
33
+ # 5. Verify
34
+ source .env.deploy
35
+ curl $WEBHOOK_ENDPOINT/health
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ 1. Create entry in Benchling
41
+ 2. Insert Canvas → "Quilt Integration"
42
+ 3. Click "Create" to make package
43
+ 4. Add files and click "Update package"
44
+
45
+ ## Documentation
46
+
47
+ - [AGENTS.md](AGENTS.md) - Complete deployment guide, architecture, configuration
48
+ - [docker/README.md](docker/README.md) - Development workflows
49
+ - [doc/RELEASE.md](doc/RELEASE.md) - Release process
50
+
51
+ ## License
52
+
53
+ Apache-2.0