### Install submitjson Client Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Install the submitjson client using npm, pnpm, or yarn. ```shell npm install submitjson # || pnpm add submitjson || yarn add submitjson ``` -------------------------------- ### Initialize SubmitJSON Client Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Example of creating a new SubmitJSON client instance with an API key, endpoint, and default options for email notifications and submission format. ```typescript // ~/submitjson.ts import SubmitJSON from 'submitjson' export const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', endpoint: 'XxXxXxXxX', options: { // set defaults for this client & override endpoint settings emailNotification: true, submissionFormat: 'raw', submissionSound: 'none', }, }) ``` -------------------------------- ### Get Project Details Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve a single project by its slug, including associated endpoints, integrations, and allowed origins. Available on all paid plans. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const project = await sj.getProject('my-website') console.log('Project', project.project) console.log('Endpoints', project.endpoints) console.log('Slack Workspaces', project.slackWorkspaces) ``` -------------------------------- ### Get All Submissions Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve paginated submissions across all endpoints and projects. Optionally filter by project. Available on all paid plans. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) // Get all submissions const { submissions, totalPages } = await sj.getSubmissions() // Get submissions from a specific project const projectSubs = await sj.getSubmissions({ project: 'my-website', }) // Get new submissions from the last day const today = await sj.getSubmissions({ period: 'day', status: 'new', order: 'desc', }) console.log('All Submissions', submissions) ``` -------------------------------- ### Get Project Endpoints Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve all endpoints associated with a specific project. Available on all paid plans. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const endpoints = await sj.getProjectEndpoints('my-website') console.log('Project Endpoints', endpoints) ``` -------------------------------- ### Get Project Submissions Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve paginated submissions for all endpoints in a specific project with optional filtering. Available on all paid plans. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) // Get all submissions for a project const { submissions } = await sj.getProjectSubmissions('my-website') // Get unread submissions from the last month const recent = await sj.getProjectSubmissions('my-website', { period: 'month', status: 'new', page: 1, }) console.log('Project Submissions', submissions) ``` -------------------------------- ### Get Single Submission Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve a single submission by its ID. Available on all paid plans. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const submission = await sj.getSubmission('xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx') console.log('Submission', submission) console.log('Submission Data', submission.data) ``` -------------------------------- ### Retrieve Paginated Endpoint Submissions Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Get paginated submissions for a specific endpoint, with options to filter by period, status, and order. Supports searching within submissions. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) // Get first page of submissions const { submissions, totalPages } = await sj.getEndpointSubmissions('XxXxXxXxX') // Get new submissions from the last week const recent = await sj.getEndpointSubmissions('XxXxXxXxX', { period: 'week', status: 'new', order: 'desc', }) // Search submissions const results = await sj.getEndpointSubmissions('XxXxXxXxX', { search: 'urgent', }) console.log('Submissions', submissions) ``` -------------------------------- ### Initialize and Submit Data Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Import the client, create an instance with your API key and endpoint, and then submit data. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', endpoint: 'XxXxXxXxX' }) const data = await sj.submit({ name: 'Yo Yoerson', message: 'Yo', powerLevel: 9001, }) console.log('Submission', data) ``` -------------------------------- ### Project Methods Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Methods for retrieving and managing projects. ```APIDOC ## Projects ### getProjects Retrieves a list of all projects. #### Parameters - **query** (object) - Optional - Query parameters for filtering and pagination. #### Returns `Promise` - A promise that resolves with an array of projects. ``` ```APIDOC ## Projects ### getProject Retrieves a specific project by its slug. #### Parameters - **slug** - The slug of the project to retrieve. #### Returns `Promise` - A promise that resolves with the project details. ``` ```APIDOC ## Projects ### getProjectEndpoints Retrieves a list of endpoints associated with a specific project. #### Parameters - **slug** - The slug of the project. #### Returns `Promise` - A promise that resolves with an array of endpoints for the project. ``` ```APIDOC ## Projects ### getProjectSubmissions Retrieves submissions for a specific project. #### Parameters - **slug** - The slug of the project. - **query** (object) - Optional - Query parameters for filtering and pagination. #### Returns `Promise` - A promise that resolves with an array of submissions for the project. ``` -------------------------------- ### getProjects() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves all projects for the authenticated user, with options to sort by name, creation date, submission count, or activity. ```APIDOC ## GET getProjects() ### Description Retrieves all projects for the authenticated user. Optionally sort by various criteria. Available on all paid plans. ### Method GET ### Endpoint (Not explicitly defined, inferred as an API endpoint for retrieving projects) ### Parameters #### Path Parameters None #### Query Parameters - **sort** (string) - Optional - Specifies the sorting order. Allowed values: 'name', 'new', 'old', 'submissions', 'activity'. Defaults to 'name'. #### Request Body None ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) // Get all projects sorted by name (default) const projects = await sj.getProjects() // Get projects sorted by submission count const busyProjects = await sj.getProjects({ sort: 'submissions' }) console.log('Projects', projects) ``` ### Response #### Success Response (200) - **Project[]** (Promise) - A promise that resolves with an array of Project objects. #### Response Example (Response structure for Project[] not explicitly defined in source) ``` -------------------------------- ### Retrieve Projects with Sorting Options Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Fetch all projects associated with the authenticated user. This function is available on paid plans and allows sorting by name, date, submission count, or activity. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) // Get all projects sorted by name (default) const projects = await sj.getProjects() // Get projects sorted by submission count const busyProjects = await sj.getProjects({ sort: 'submissions' }) console.log('Projects', projects) ``` -------------------------------- ### getProject() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve a single project by its slug, including associated endpoints, integrations, and allowed origins. Available on all paid plans. ```APIDOC ## getProject(slug: string) ### Description Retrieve a single project by its slug, including associated endpoints, integrations, and allowed origins. Available on all paid plans. ### Method GET (assumed based on function name and typical SDK patterns) ### Endpoint /projects/{slug} (inferred from context) ### Parameters #### Path Parameters - **slug** (string) - Required - The unique identifier for the project. ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const project = await sj.getProject('my-website') console.log('Project', project.project) console.log('Endpoints', project.endpoints) console.log('Slack Workspaces', project.slackWorkspaces) ``` ### Response #### Success Response (200) - **project** (ProjectResponse) - Details of the project. - **endpoints** (Endpoint[]) - Associated endpoints. - **slackWorkspaces** (SlackWorkspace[]) - Associated Slack workspaces. #### Response Example ```json { "project": { ... }, "endpoints": [ ... ], "slackWorkspaces": [ ... ] } ``` ``` -------------------------------- ### getProjects() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves a list of all projects associated with the account. ```APIDOC ## getProjects() ### Description Retrieves a list of all projects associated with the account. ### Method `getProjects(): Promise>` ### Parameters None ### Request Example ```javascript const projects = await sj.getProjects() ``` ### Response #### Success Response (200) - An array of project objects, each containing details like project ID and name. #### Response Example ```json [ { "id": "proj_xxxxxxxxxxxxxx", "name": "Website Forms" } ] ``` ``` -------------------------------- ### Submit Data with All Configuration Options Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Use this snippet to submit data with custom configurations for email notifications, submission format, and more. It overrides the default endpoint set during client initialization. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', endpoint: 'XxXxXxXxX', }) const data = await sj.submit({ name: 'Yo Yoerson', message: 'Yo', powerLevel: 9001, }, { emailNotification: true, emailTo: 'yo@yoerson.com', emailReplyTo: 'diff@differson.com', emailBranding: false, emailSubject: 'My custom subject line', emailFromName: 'My custom from name', submissionFormat: 'pretty', submissionSound: 'ping', recaptchaToken: 'xxxxxxxxxxx' }, 'YyYyYyYyY') // overrides the endpoint set in the configuration console.log('Submission', data) ``` -------------------------------- ### SubmitJSON Client Initialization Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Initializes a new SubmitJSON client instance. You can configure default options such as API keys, endpoints, and notification settings. ```APIDOC ## Client Initialization ### Description Import and create a new Submit JSON client instance. You can include your endpoint for easier `submit` calls and pass in default options per client to override the current endpoint settings. ### Constructor `new SubmitJSON(config: SubmitJSONConfig)` ### Parameters #### config (SubmitJSONConfig) - **apiKey** (string) - Required - Your API key. - **secretKey** (string) - Optional - Your secret key. - **endpoint** (string) - Optional - The API endpoint URL. - **options** (SubmitOptions) - Optional - Default options for the client. ### Example ```ts import SubmitJSON from 'submitjson' export const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', endpoint: 'XxXxXxXxX', options: { emailNotification: true, submissionFormat: 'raw', submissionSound: 'none', }, }) ``` ``` -------------------------------- ### submit() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Submits data to an endpoint in real-time. It accepts JSON data, a string, or FormData, with optional configuration for overriding default settings or specifying a custom endpoint. ```APIDOC ## POST submit() ### Description Submits data to an endpoint and provides real-time notifications. The data can be a JSON object, JSON string, or FormData. Optional configuration can override default settings or specify a custom endpoint. ### Method POST ### Endpoint (Not explicitly defined, inferred as the endpoint provided in configuration or arguments) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **data** (Record | string | FormData) - Required - The data to submit. - **options** (SubmitOptions) - Optional - Configuration to override default settings. - **endpoint** (string) - Optional - A custom endpoint to submit data to, overriding the default. ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', endpoint: 'XxXxXxXxX', }) const data = await sj.submit({ name: 'Yo Yoerson', message: 'Yo', powerLevel: 9001, }, { emailNotification: true, emailTo: 'yo@yoerson.com', emailReplyTo: 'diff@differson.com', emailBranding: false, emailSubject: 'My custom subject line', emailFromName: 'My custom from name', submissionFormat: 'pretty', submissionSound: 'ping', recaptchaToken: 'xxxxxxxxxxx' }, 'YyYyYyYyY') // overrides the endpoint set in the configuration console.log('Submission', data) ``` ### Response #### Success Response (200) - **Submission** (Promise) - A promise that resolves with the submission details. #### Response Example (Response structure not explicitly defined in source, but implies details of the submission) ``` -------------------------------- ### getProject() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves details for a specific project by its ID. ```APIDOC ## getProject(projectId: string) ### Description Retrieves details for a specific project by its ID. ### Method `getProject(projectId: string): Promise` ### Parameters #### Path Parameters - **projectId** (string) - Required - The ID of the project to retrieve. #### Query Parameters None #### Request Body None ### Request Example ```javascript const projectDetails = await sj.getProject('proj_xxxxxxxxxxxxxx') ``` ### Response #### Success Response (200) - A project object containing details such as ID and name. #### Response Example ```json { "id": "proj_xxxxxxxxxxxxxx", "name": "Website Forms" } ``` ``` -------------------------------- ### Initialize Multiple SubmitJSON Clients Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Initialize multiple SubmitJSON clients to manage different concerns, such as separate contact forms or user notification systems. This allows for distinct configurations and endpoints. ```typescript // submitjson.ts import SubmitJSON from 'submitjson' export const contactForm = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', endpoint: 'XxXxXxXxX', }) export const userSignupNotification = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', endpoint: 'ZzZzZzZzZ', }) // somewhere else in your code const data = { name: 'Yo Yoerson', message: 'Yo' } await contactForm.submit(data) await userSignupNotification.submit(data) ``` -------------------------------- ### getProjectEndpoints() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve all endpoints associated with a specific project. Available on all paid plans. ```APIDOC ## getProjectEndpoints(slug: string) ### Description Retrieve all endpoints associated with a specific project. Available on all paid plans. ### Method GET (assumed based on function name and typical SDK patterns) ### Endpoint /projects/{slug}/endpoints (inferred from context) ### Parameters #### Path Parameters - **slug** (string) - Required - The unique identifier for the project. ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const endpoints = await sj.getProjectEndpoints('my-website') console.log('Project Endpoints', endpoints) ``` ### Response #### Success Response (200) - **endpoints** (Endpoint[]) - An array of endpoint objects associated with the project. #### Response Example ```json [ { ... }, { ... } ] ``` ``` -------------------------------- ### getProjectSubmissions() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve paginated submissions for all endpoints in a specific project with optional filtering. Available on all paid plans. ```APIDOC ## getProjectSubmissions(slug: string, query?: SubmissionsQuery) ### Description Retrieve paginated submissions for all endpoints in a specific project with optional filtering. Available on all paid plans. ### Method GET (assumed based on function name and typical SDK patterns) ### Endpoint /projects/{slug}/submissions (inferred from context) ### Parameters #### Path Parameters - **slug** (string) - Required - The unique identifier for the project. #### Query Parameters - **query** (SubmissionsQuery) - Optional - An object for filtering submissions. See SubmissionsQuery definition for available fields (e.g., period, status, page). ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) // Get all submissions for a project const { submissions } = await sj.getProjectSubmissions('my-website') // Get unread submissions from the last month const recent = await sj.getProjectSubmissions('my-website', { period: 'month', status: 'new', page: 1, }) console.log('Project Submissions', submissions) ``` ### Response #### Success Response (200) - **submissions** (Submission[]) - An array of submission objects. - **submissionCount** (number) - The total number of submissions matching the query. - **totalPages** (number) - The total number of pages available. - **currentPage** (number) - The current page number. #### Response Example ```json { "submissions": [ ... ], "submissionCount": 100, "totalPages": 10, "currentPage": 1 } ``` ``` -------------------------------- ### Retrieve Endpoints with Sorting Options Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Fetch all endpoints for the authenticated user. This function is available on paid plans and supports sorting by name, date, submission count, or activity. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', // required for public API routes }) // Get all endpoints sorted by name (default) const endpoints = await sj.getEndpoints() // Get endpoints sorted by most recent submissions const recentEndpoints = await sj.getEndpoints({ sort: 'activity' }) console.log('Endpoints', endpoints) ``` -------------------------------- ### submit() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Submits data to a specified endpoint. This is the primary method for sending new submissions. ```APIDOC ## submit() ### Description Submits data to a specified endpoint. This is the primary method for sending new submissions. ### Method `submit(data: object, options?: { endpoint?: string }): Promise ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **data** (object) - Required - The data payload to submit. - **options** (object) - Optional - Additional options for the submission. - **endpoint** (string) - Optional - The specific endpoint to submit to. If not provided, the default endpoint configured during client initialization will be used. ### Request Example ```javascript const data = await sj.submit({ name: 'Yo Yoerson', message: 'Yo', powerLevel: 9001, }) ``` ### Response #### Success Response (200) - **submissionId** (string) - The unique identifier for the submitted data. - **status** (string) - The status of the submission (e.g., 'success', 'failed'). #### Response Example ```json { "submissionId": "sub_xxxxxxxxxxxxxx", "status": "success" } ``` ``` -------------------------------- ### Submission Methods Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Methods for submitting data and managing individual submissions. ```APIDOC ## Submission ### submit Submits data to the API. #### Parameters - **data** - The data payload to submit. - **options** (object) - Optional - Submission-specific options. - **endpoint** (string) - Optional - The specific endpoint to submit to. #### Returns `Promise` - A promise that resolves with the submission details. ``` ```APIDOC ## Submission ### getSubmission Retrieves a specific submission by its ID. #### Parameters - **id** - The ID of the submission to retrieve. #### Returns `Promise` - A promise that resolves with the submission details. ``` ```APIDOC ## Submission ### deleteSubmission Deletes a specific submission by its ID. #### Parameters - **id** - The ID of the submission to delete. #### Returns `Promise<{ success: boolean }>` - A promise that resolves with a success status. ``` -------------------------------- ### getEndpoints() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves a list of all available endpoints associated with the account. ```APIDOC ## getEndpoints() ### Description Retrieves a list of all available endpoints associated with the account. ### Method `getEndpoints(): Promise>` ### Parameters None ### Request Example ```javascript const endpoints = await sj.getEndpoints() ``` ### Response #### Success Response (200) - An array of endpoint objects, each containing details like endpoint ID, name, and creation date. #### Response Example ```json [ { "id": "ep_xxxxxxxxxxxxxx", "name": "Contact Form", "createdAt": "2023-01-01T12:00:00Z" } ] ``` ``` -------------------------------- ### getProjectSubmissions() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves a list of all submissions for all endpoints within a specific project. ```APIDOC ## getProjectSubmissions(projectId: string) ### Description Retrieves a list of all submissions for all endpoints within a specific project. ### Method `getProjectSubmissions(projectId: string): Promise>` ### Parameters #### Path Parameters - **projectId** (string) - Required - The ID of the project whose submissions are to be retrieved. #### Query Parameters None #### Request Body None ### Request Example ```javascript const projectSubmissions = await sj.getProjectSubmissions('proj_xxxxxxxxxxxxxx') ``` ### Response #### Success Response (200) - An array of submission objects from all endpoints within the specified project. #### Response Example ```json [ { "submissionId": "sub_xxxxxxxxxxxxxx", "endpointId": "ep_xxxxxxxxxxxxxx", "data": { "name": "Yo Yoerson", "message": "Yo" }, "createdAt": "2023-01-01T12:05:00Z" } ] ``` ``` -------------------------------- ### Endpoint Methods Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Methods for retrieving and managing endpoints. ```APIDOC ## Endpoints ### getEndpoints Retrieves a list of all endpoints. #### Parameters - **query** (object) - Optional - Query parameters for filtering and pagination. #### Returns `Promise` - A promise that resolves with an array of endpoints. ``` ```APIDOC ## Endpoints ### getEndpoint Retrieves a specific endpoint by its slug. #### Parameters - **slug** - The slug of the endpoint to retrieve. #### Returns `Promise` - A promise that resolves with the endpoint details. ``` ```APIDOC ## Endpoints ### getEndpointSubmissions Retrieves submissions for a specific endpoint. #### Parameters - **slug** - The slug of the endpoint. - **query** (object) - Optional - Query parameters for filtering and pagination. #### Returns `Promise` - A promise that resolves with an array of submissions for the endpoint. ``` -------------------------------- ### getSubmissions() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve paginated submissions across all endpoints and projects. Optionally filter by project. Available on all paid plans. ```APIDOC ## getSubmissions(query?: SubmissionsQuery & { project?: string }) ### Description Retrieve paginated submissions across all endpoints and projects. Optionally filter by project. Available on all paid plans. ### Method GET (assumed based on function name and typical SDK patterns) ### Endpoint /submissions (inferred from context) ### Parameters #### Query Parameters - **query** (SubmissionsQuery & { project?: string }) - Optional - An object for filtering submissions. Can include fields from SubmissionsQuery plus an optional `project` field to filter by a specific project. - **project** (string) - Optional - The unique identifier for the project to filter submissions by. ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) // Get all submissions const { submissions, totalPages } = await sj.getSubmissions() // Get submissions from a specific project const projectSubs = await sj.getSubmissions({ project: 'my-website', }) // Get new submissions from the last day const today = await sj.getSubmissions({ period: 'day', status: 'new', order: 'desc', }) console.log('All Submissions', submissions) ``` ### Response #### Success Response (200) - **submissions** (Submission[]) - An array of submission objects. - **submissionCount** (number) - The total number of submissions matching the query. - **totalPages** (number) - The total number of pages available. - **currentPage** (number) - The current page number. #### Response Example ```json { "submissions": [ ... ], "submissionCount": 500, "totalPages": 50, "currentPage": 1 } ``` ``` -------------------------------- ### Retrieve a Single Endpoint by Slug Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Fetch details for a specific endpoint using its unique slug. This requires authentication with an API key and secret key and is available on paid plans. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const endpoint = await sj.getEndpoint('XxXxXxXxX') console.log('Endpoint', endpoint.endpoint) console.log('Webhooks', endpoint.webhooks) console.log('Origins', endpoint.origins) ``` -------------------------------- ### getProjectEndpoints() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves a list of endpoints associated with a specific project. ```APIDOC ## getProjectEndpoints(projectId: string) ### Description Retrieves a list of endpoints associated with a specific project. ### Method `getProjectEndpoints(projectId: string): Promise>` ### Parameters #### Path Parameters - **projectId** (string) - Required - The ID of the project whose endpoints are to be retrieved. #### Query Parameters None #### Request Body None ### Request Example ```javascript const projectEndpoints = await sj.getProjectEndpoints('proj_xxxxxxxxxxxxxx') ``` ### Response #### Success Response (200) - An array of endpoint objects associated with the specified project. #### Response Example ```json [ { "id": "ep_xxxxxxxxxxxxxx", "name": "Contact Form" } ] ``` ``` -------------------------------- ### getEndpoints() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves all endpoints associated with the authenticated user. Supports sorting by name, creation date, submission count, or activity. ```APIDOC ## GET getEndpoints() ### Description Retrieves all endpoints for the authenticated user. This feature is available on all paid plans. Endpoints can be sorted by various criteria. ### Method GET ### Endpoint (Not explicitly defined, inferred as an API endpoint for retrieving endpoints) ### Parameters #### Path Parameters None #### Query Parameters - **sort** (string) - Optional - Specifies the sorting order. Allowed values: 'name', 'new', 'old', 'submissions', 'activity'. Defaults to 'name'. #### Request Body None ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', // required for public API routes }) // Get all endpoints sorted by name (default) const endpoints = await sj.getEndpoints() // Get endpoints sorted by most recent submissions const recentEndpoints = await sj.getEndpoints({ sort: 'activity' }) console.log('Endpoints', endpoints) ``` ### Response #### Success Response (200) - **Endpoint[]** (Promise) - A promise that resolves with an array of Endpoint objects. #### Response Example (Response structure for Endpoint[] not explicitly defined in source) ``` -------------------------------- ### SubmitJSON Client Configuration Interfaces Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Defines the TypeScript interfaces for configuring the SubmitJSON client, its options, and query parameters for fetching submissions. ```typescript interface SubmitJSONConfig { apiKey: string secretKey?: string endpoint?: string options?: SubmitOptions } interface SubmitOptions { emailNotification?: boolean emailTo?: string emailReplyTo?: string emailBranding?: boolean emailSubject?: string emailFromName?: string submissionFormat?: 'pretty' | 'raw' | 'custom' submissionTemplate?: string submissionSound?: 'none' | 'beep' | 'blip' | 'block' | 'coin' | 'ding' | 'dink' | 'honk' | 'jump' | 'ping' | 'pong' | 'snare' recaptchaToken?: string turnstileToken?: string hcaptchaToken?: string discordNotification?: boolean slackNotification?: boolean telegramNotification?: boolean } interface SubmissionsQuery { page?: number order?: 'asc' | 'desc' period?: 'day' | 'week' | 'month' | '3months' | '6months' | 'year' | 'all' search?: string status?: 'all' | 'new' | 'seen' } ``` -------------------------------- ### getEndpoint() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves a single endpoint by its unique slug. This function is available on all paid plans. ```APIDOC ## GET getEndpoint() ### Description Retrieves a single endpoint by its slug. This function is available on all paid plans. ### Method GET ### Endpoint (Not explicitly defined, inferred as an API endpoint for retrieving a single endpoint) ### Parameters #### Path Parameters - **slug** (string) - Required - The unique identifier (slug) of the endpoint. #### Query Parameters None #### Request Body None ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const endpoint = await sj.getEndpoint('XxXxXxXxX') console.log('Endpoint', endpoint.endpoint) console.log('Webhooks', endpoint.webhooks) console.log('Origins', endpoint.origins) ``` ### Response #### Success Response (200) - **EndpointResponse** (Promise) - A promise that resolves with the detailed response for the specified endpoint. #### Response Example (Response structure for EndpointResponse not explicitly defined in source, but example shows `endpoint`, `webhooks`, and `origins` properties) ``` -------------------------------- ### getSubmissions() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves a list of all submissions across all endpoints and projects. ```APIDOC ## getSubmissions() ### Description Retrieves a list of all submissions across all endpoints and projects. ### Method `getSubmissions(): Promise>` ### Parameters None ### Request Example ```javascript const allSubmissions = await sj.getSubmissions() ``` ### Response #### Success Response (200) - An array of all submission objects. #### Response Example ```json [ { "submissionId": "sub_xxxxxxxxxxxxxx", "endpointId": "ep_xxxxxxxxxxxxxx", "projectId": "proj_xxxxxxxxxxxxxx", "data": { "name": "Yo Yoerson", "message": "Yo" }, "createdAt": "2023-01-01T12:05:00Z" } ] ``` ``` -------------------------------- ### getSubmission() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieve a single submission by its ID. Available on all paid plans. ```APIDOC ## getSubmission(id: string) ### Description Retrieve a single submission by its ID. Available on all paid plans. ### Method GET (assumed based on function name and typical SDK patterns) ### Endpoint /submissions/{id} (inferred from context) ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier for the submission. ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const submission = await sj.getSubmission('xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx') console.log('Submission', submission) console.log('Submission Data', submission.data) ``` ### Response #### Success Response (200) - **submission** (Submission) - The submission object. #### Response Example ```json { "id": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "data": { ... }, "createdAt": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### getEndpoint() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves details for a specific endpoint by its ID. ```APIDOC ## getEndpoint(endpointId: string) ### Description Retrieves details for a specific endpoint by its ID. ### Method `getEndpoint(endpointId: string): Promise` ### Parameters #### Path Parameters - **endpointId** (string) - Required - The ID of the endpoint to retrieve. #### Query Parameters None #### Request Body None ### Request Example ```javascript const endpointDetails = await sj.getEndpoint('ep_xxxxxxxxxxxxxx') ``` ### Response #### Success Response (200) - An endpoint object containing details such as ID, name, and creation date. #### Response Example ```json { "id": "ep_xxxxxxxxxxxxxx", "name": "Contact Form", "createdAt": "2023-01-01T12:00:00Z" } ``` ``` -------------------------------- ### Submissions Query Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Defines the structure for querying submissions, allowing filtering by page, order, period, search, and status. ```APIDOC ## Submissions Query Parameters ### `SubmissionsQuery` Interface This interface defines the available parameters for querying submissions. #### Parameters - **page** (number) - Optional - The page number for pagination. - **order** ('asc' | 'desc') - Optional - The order of results (ascending or descending). - **period** ('day' | 'week' | 'month' | '3months' | '6months' | 'year' | 'all') - Optional - The time period for filtering submissions. - **search** (string) - Optional - A search term to filter submissions. - **status** ('all' | 'new' | 'seen') - Optional - The status of submissions to filter by. ``` -------------------------------- ### SubmitJSON Class Definition Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Outlines the methods available on the SubmitJSON class for managing submissions, endpoints, and projects. ```typescript class SubmitJSON { constructor(config: SubmitJSONConfig) // Submission submit(data, options?, endpoint?): Promise // Endpoints getEndpoints(query?): Promise getEndpoint(slug): Promise getEndpointSubmissions(slug, query?): Promise // Projects getProjects(query?): Promise getProject(slug): Promise getProjectEndpoints(slug): Promise getProjectSubmissions(slug, query?): Promise // Submissions getSubmissions(query?): Promise getSubmission(id): Promise deleteSubmission(id): Promise<{ success: boolean }> } ``` -------------------------------- ### getEndpointSubmissions() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves paginated submissions for a specific endpoint, with options for filtering by period, status, order, and searching. ```APIDOC ## GET getEndpointSubmissions() ### Description Retrieves paginated submissions for a specific endpoint. Supports filtering by period, status, order, and searching. Available on all paid plans. ### Method GET ### Endpoint (Not explicitly defined, inferred as an API endpoint for retrieving endpoint submissions) ### Parameters #### Path Parameters - **slug** (string) - Required - The unique identifier (slug) of the endpoint. #### Query Parameters - **query** (SubmissionsQuery) - Optional - An object containing query parameters for filtering and searching submissions. - **period** (string) - Optional - The time period for submissions (e.g., 'week'). - **status** (string) - Optional - The status of submissions (e.g., 'new'). - **order** (string) - Optional - The order of submissions (e.g., 'desc'). - **search** (string) - Optional - A search term to filter submissions. #### Request Body None ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) // Get first page of submissions const { submissions, totalPages } = await sj.getEndpointSubmissions('XxXxXxXxX') // Get new submissions from the last week const recent = await sj.getEndpointSubmissions('XxXxXxXxX', { period: 'week', status: 'new', order: 'desc', }) // Search submissions const results = await sj.getEndpointSubmissions('XxXxXxXxX', { search: 'urgent', }) console.log('Submissions', submissions) ``` ### Response #### Success Response (200) - **submissions** (Submission[]) - An array of submission objects. - **submissionCount** (number) - The total count of submissions. - **totalPages** (number) - The total number of pages available. - **currentPage** (number) - The current page number. #### Response Example (Response structure for submissions not explicitly defined in source, but example shows `submissions`, `totalPages`, `currentPage` properties) ``` -------------------------------- ### getSubmission() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves details for a specific submission by its ID. ```APIDOC ## getSubmission(submissionId: string) ### Description Retrieves details for a specific submission by its ID. ### Method `getSubmission(submissionId: string): Promise` ### Parameters #### Path Parameters - **submissionId** (string) - Required - The ID of the submission to retrieve. #### Query Parameters None #### Request Body None ### Request Example ```javascript const submissionDetails = await sj.getSubmission('sub_xxxxxxxxxxxxxx') ``` ### Response #### Success Response (200) - A submission object containing details such as submission ID, data, and creation timestamp. #### Response Example ```json { "submissionId": "sub_xxxxxxxxxxxxxx", "endpointId": "ep_xxxxxxxxxxxxxx", "projectId": "proj_xxxxxxxxxxxxxx", "data": { "name": "Yo Yoerson", "message": "Yo" }, "createdAt": "2023-01-01T12:05:00Z" } ``` ``` -------------------------------- ### getEndpointSubmissions() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Retrieves a list of submissions for a specific endpoint. ```APIDOC ## getEndpointSubmissions(endpointId: string) ### Description Retrieves a list of submissions for a specific endpoint. ### Method `getEndpointSubmissions(endpointId: string): Promise>` ### Parameters #### Path Parameters - **endpointId** (string) - Required - The ID of the endpoint whose submissions are to be retrieved. #### Query Parameters None #### Request Body None ### Request Example ```javascript const submissions = await sj.getEndpointSubmissions('ep_xxxxxxxxxxxxxx') ``` ### Response #### Success Response (200) - An array of submission objects for the specified endpoint. #### Response Example ```json [ { "submissionId": "sub_xxxxxxxxxxxxxx", "data": { "name": "Yo Yoerson", "message": "Yo" }, "createdAt": "2023-01-01T12:05:00Z" } ] ``` ``` -------------------------------- ### deleteSubmission() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Delete a submission by its ID. This action decrements the endpoint's submission count and cannot be undone. Available on all paid plans. ```APIDOC ## deleteSubmission(id: string) ### Description Delete a submission by its ID. This action decrements the endpoint's submission count and cannot be undone. Available on all paid plans. ### Method DELETE (assumed based on function name and typical SDK patterns) ### Endpoint /submissions/{id} (inferred from context) ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier for the submission to delete. ### Request Example ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const result = await sj.deleteSubmission('xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx') ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the deletion was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### deleteSubmission() Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Deletes a specific submission by its ID. ```APIDOC ## deleteSubmission(submissionId: string) ### Description Deletes a specific submission by its ID. ### Method `deleteSubmission(submissionId: string): Promise` ### Parameters #### Path Parameters - **submissionId** (string) - Required - The ID of the submission to delete. #### Query Parameters None #### Request Body None ### Request Example ```javascript const deleteResult = await sj.deleteSubmission('sub_xxxxxxxxxxxxxx') ``` ### Response #### Success Response (200) - An object indicating the result of the deletion operation. #### Response Example ```json { "message": "Submission deleted successfully." } ``` ``` -------------------------------- ### Delete Submission Source: https://github.com/dylanmcgowan/submitjson/blob/master/README.md Delete a submission by its ID. This action decrements the endpoint's submission count and cannot be undone. Available on all paid plans. ```typescript import SubmitJSON from 'submitjson' const sj = new SubmitJSON({ apiKey: 'sjk_xxxxxxxxxxxxxx', secretKey: 'sjsk_xxxxxxxxxxxxxx', }) const result = await sj.deleteSubmission('xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.