Skip to main content

WebsitesPublicApiRouter

Overview

The WebsitesPublicApiRouter class exposes public API endpoints for managing website configurations within an organization. It allows external systems to register, retrieve, update, and delete website domains and settings.

Base Configuration

Environments

All requests should be directed to the following base URLs depending on the environment:

EnvironmentBase URL
Productionhttps://api.payments.ai/v1/public-api
Staginghttps://staging-api.payments.ai/v1/public-api

Authentication & Authorization

  • Authentication: Requires a valid API Key passed in the Authorization header.
  • Role Required: The API Key must belong to a user with the EDITOR role (or higher) in the target organization.

Endpoints

1. Create Website

Registers a new website (and its domain/URL) for the specified organization.

  • Method: POST
  • Route: /organizations/{organizationId}/websites

Request Parameters

Path Parameters:

ParameterTypeRequiredDescription
organizationIdstringYesThe unique identifier (UUID) of the organization.

Body Parameters (JSON):

ParameterTypeRequiredConstraintsDescription
namestringYesMax 22 charsThe internal display name for the website.
urlstringYesMax 50 chars, Valid URLThe public domain/URL of the website (e.g., https://myshop.com).

Example Request

curl --location --request POST 'https://api.payments.ai/v1/public-api/organizations/org_12345/websites' \
--header 'Content-Type: application/json' \
--header 'Authorization: YOUR_API_KEY' \
--data '{
"name": "Summer Sale Store",
"url": "https://sale.myshop.com"
}'

Example Response (201 Created)

{
"type": "object",
"data": {
"id": "web_8829304",
"organizationId": "org_12345",
"name": "Summer Sale Store",
"url": "https://sale.myshop.com"
}
}


2. Retrieve Website

Fetches the configuration details of a specific website.

  • Method: GET
  • Route: /organizations/{organizationId}/websites/{websiteId}

Request Parameters

Path Parameters:

ParameterTypeRequiredDescription
organizationIdstringYesThe UUID of the organization.
websiteIdstringYesThe unique identifier of the website to retrieve.

Example Request

curl --location --request GET 'https://api.payments.ai/v1/public-api/organizations/org_12345/websites/web_98765' \
--header 'Authorization: YOUR_API_KEY'

Example Response (200 OK)

{
"type": "object",
"data": {
"id": "web_98765",
"organizationId": "org_12345",
"name": "Summer Sale Store",
"url": "https://sale.myshop.com"
}
}


3. Update Website

Updates the name or domain URL of an existing website.

  • Method: PUT
  • Route: /organizations/{organizationId}/websites/{websiteId}

Request Parameters

Path Parameters:

ParameterTypeRequiredDescription
organizationIdstringYesThe UUID of the organization.
websiteIdstringYesThe unique identifier of the website to update.

Body Parameters (JSON):

ParameterTypeRequiredConstraintsDescription
namestringYesMax 22 charsThe new display name.
urlstringYesMax 50 chars, Valid URLThe new public domain/URL.

Example Request

curl --location --request PUT 'https://api.payments.ai/v1/public-api/organizations/org_12345/websites/web_98765' \
--header 'Content-Type: application/json' \
--header 'Authorization: YOUR_API_KEY' \
--data '{
"name": "Winter Sale Store",
"url": "https://winter.myshop.com"
}'

Example Response (200 OK)

{
"type": "object",
"data": {
"id": "web_98765",
"organizationId": "org_12345",
"name": "Winter Sale Store",
"url": "https://winter.myshop.com"
}
}


4. Delete Website

Permanently removes a website configuration from the organization.

  • Method: DELETE
  • Route: /organizations/{organizationId}/websites/{websiteId}

Request Parameters

Path Parameters:

ParameterTypeRequiredDescription
organizationIdstringYesThe UUID of the organization.
websiteIdstringYesThe unique identifier of the website to delete.

Example Request

curl --location --request DELETE 'https://api.payments.ai/v1/public-api/organizations/org_12345/websites/web_98765' \
--header 'Authorization: YOUR_API_KEY'

Example Response (200 OK)

{
"success": true
}


Error Handling

The API returns standard HTTP status codes to indicate the success or failure of requests.

Status CodeDescription
200 OKRequest processed successfully.
201 CreatedResource created successfully.
400 Bad RequestValidation failed (e.g., name exceeds 22 chars or invalid url format).
401 UnauthorizedMissing or invalid API Key.
403 ForbiddenUser does not have the EDITOR role or access is blocked.
404 Not FoundOrganization or Website ID not found.

Example Error Response (400 Bad Request)

{
"code": "VALIDATION_ERROR",
"message": "Validation failed",
"details": [
{
"field": "name",
"message": "String must contain at most 22 character(s)"
}
]
}