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:
| Environment | Base URL |
|---|---|
| Production | https://api.payments.ai/v1/public-api |
| Staging | https://staging-api.payments.ai/v1/public-api |
Authentication & Authorization
- Authentication: Requires a valid API Key passed in the
Authorizationheader. - 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
organizationId | string | Yes | The unique identifier (UUID) of the organization. |
Body Parameters (JSON):
| Parameter | Type | Required | Constraints | Description |
|---|---|---|---|---|
name | string | Yes | Max 22 chars | The internal display name for the website. |
url | string | Yes | Max 50 chars, Valid URL | The 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
organizationId | string | Yes | The UUID of the organization. |
websiteId | string | Yes | The 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
organizationId | string | Yes | The UUID of the organization. |
websiteId | string | Yes | The unique identifier of the website to update. |
Body Parameters (JSON):
| Parameter | Type | Required | Constraints | Description |
|---|---|---|---|---|
name | string | Yes | Max 22 chars | The new display name. |
url | string | Yes | Max 50 chars, Valid URL | The 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
organizationId | string | Yes | The UUID of the organization. |
websiteId | string | Yes | The 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 Code | Description |
|---|---|
| 200 OK | Request processed successfully. |
| 201 Created | Resource created successfully. |
| 400 Bad Request | Validation failed (e.g., name exceeds 22 chars or invalid url format). |
| 401 Unauthorized | Missing or invalid API Key. |
| 403 Forbidden | User does not have the EDITOR role or access is blocked. |
| 404 Not Found | Organization 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)"
}
]
}