-
Notifications
You must be signed in to change notification settings - Fork 683
Add webhooks docs and update routes #877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e8183a1
add webhooks docs and update routes
0div ff85fdc
do not capitalize first letters of words in titles
0div e829735
Update apps/web/src/app/(docs)/docs/sandbox/lifecycle-events-webhooks…
0div a7e5ffa
address PR comments
0div 13eee21
Merge branch 'add-webhooks-docs-e2b-2920' of https://github.com/e2b-d…
0div 0351954
Merge branch 'main' of https://github.com/e2b-dev/E2B into add-webhoo…
0div df183bd
update docs with latest return values
0div dc8ec50
remove whitespace
0div 4edb8b3
typo in example var
0div 4595fe8
better naming for metadata keys
0div File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
apps/web/src/app/(docs)/docs/sandbox/lifecycle-events-api/page.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
254 changes: 254 additions & 0 deletions
254
apps/web/src/app/(docs)/docs/sandbox/lifecycle-events-webhooks/page.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,254 @@ | ||||||
| # Sandbox Lifecycle Webhooks | ||||||
mlejva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| Webhooks provide a way for notifications to be delivered to an external web server whenever certain sandbox lifecycle events occur. | ||||||
| This allows you to receive real-time updates about sandbox creation, updates, and termination without having to poll the API. | ||||||
| All webhook requests require authentication using your team [API key](/docs/api-key#where-to-find-api-key). | ||||||
|
|
||||||
| ## Webhook Management | ||||||
mlejva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| ### Register Webhook | ||||||
mlejva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| Register a new webhook to receive sandbox lifecycle events. | ||||||
| The webhook will be registered for the team ID associated with your API key. You will receive webhook notifications for sandbox lifecycle events from sandboxes created by your team. | ||||||
0div marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
|
|
||||||
| <CodeGroup> | ||||||
| ```js | ||||||
| // Register a new webhook | ||||||
| const resp = await fetch( | ||||||
| 'https://api.e2b.app/events/webhooks/sandboxes', | ||||||
| { | ||||||
| method: 'POST', | ||||||
| headers: { | ||||||
| 'X-API-Key': E2B_API_KEY, | ||||||
| 'Content-Type': 'application/json', | ||||||
| }, | ||||||
| body: JSON.stringify({ | ||||||
| url: 'https://your-webhook-endpoint.com/webhook', | ||||||
| events: ['create', 'kill', 'update'] | ||||||
| }), | ||||||
| } | ||||||
| ) | ||||||
|
|
||||||
| if (resp.status === 201) { | ||||||
| console.log('Webhook registered successfully') | ||||||
| } | ||||||
| ``` | ||||||
| ```python | ||||||
| import requests | ||||||
|
|
||||||
| # Register a new webhook | ||||||
| resp = requests.post( | ||||||
| "https://api.e2b.app/events/webhooks/sandboxes", | ||||||
| headers={ | ||||||
| "X-API-Key": E2B_API_KEY, | ||||||
| "Content-Type": "application/json", | ||||||
| }, | ||||||
| json={ | ||||||
| "url": "https://your-webhook-endpoint.com/webhook", | ||||||
| "events": ["create", "kill", "update"] | ||||||
| } | ||||||
| ) | ||||||
|
|
||||||
| if resp.status_code == 201: | ||||||
| print("Webhook registered successfully") | ||||||
| ``` | ||||||
| </CodeGroup> | ||||||
|
|
||||||
|
|
||||||
| ### Get Webhook Configuration | ||||||
mlejva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| Retrieve the current webhook configuration for your team. | ||||||
|
|
||||||
| <CodeGroup> | ||||||
| ```js | ||||||
| // Get current webhook configuration | ||||||
| const resp = await fetch( | ||||||
| 'https://api.e2b.app/events/webhooks/sandboxes', | ||||||
| { | ||||||
| method: 'GET', | ||||||
| headers: { | ||||||
| 'X-API-Key': E2B_API_KEY, | ||||||
| }, | ||||||
| } | ||||||
| ) | ||||||
| const webhookConfig = await resp.json() | ||||||
| console.log(webhookConfig) | ||||||
| // { | ||||||
| // "teamID": "460355b3-4f64-48f9-9a16-4442817f79f5", | ||||||
| // "url": "https://your-webhook-endpoint.com/webhook", | ||||||
| // "events": ["create", "kill"] | ||||||
| // } | ||||||
|
|
||||||
| ``` | ||||||
| ```python | ||||||
| import requests | ||||||
|
|
||||||
| # Get current webhook configuration | ||||||
| resp = requests.get( | ||||||
| "https://api.e2b.app/events/webhooks/sandboxes", | ||||||
| headers={ | ||||||
| "X-API-Key": E2B_API_KEY, | ||||||
| } | ||||||
| ) | ||||||
| webhook_config = resp.json() | ||||||
|
|
||||||
| print(webhook_config) | ||||||
| # { | ||||||
| # "teamID": "460355b3-4f64-48f9-9a16-4442817f79f5", | ||||||
| # "url": "https://your-webhook-endpoint.com/webhook", | ||||||
| # "events": ["create", "kill"] | ||||||
| # } | ||||||
| ``` | ||||||
| </CodeGroup> | ||||||
|
|
||||||
| ### Update Webhook Configuration | ||||||
|
||||||
| ### Update Webhook Configuration | |
| ### Update webhook configuration |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| ### Delete Webhook | |
| ### Delete webhook |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| ### Test Webhook | |
| ### Test webhook |
mlejva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mlejva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mlejva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mlejva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
0div marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
0div marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.