Skip to main content

POST /resources

Creates a new resource associated with an existing wrapper. The resource will be initialized with startPeriod and endPeriod set to null.

Authentication

This endpoint requires authentication.

Request Body

wrapper_id
string
required
ID of the wrapper to associate with this resource. The wrapper must already exist in the system.
name
string
required
Name of the resource
type
string
required
Type of the resource

Response

Returns the created resource object.
id
string
required
Unique identifier for the created resource (MongoDB ObjectId)
wrapper_id
string
required
ID of the wrapper associated with this resource
name
string
required
Name of the resource
type
string
required
Type of the resource
startPeriod
datetime
Start period timestamp for the resource (null on creation)
endPeriod
datetime
End period timestamp for the resource (null on creation)

Example Request

curl -X POST "https://api.example.com/resources" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "wrapper_id": "wrapper_123",
    "name": "Production Database",
    "type": "database"
  }'

Example Response

{
  "id": "507f1f77bcf86cd799439011",
  "wrapper_id": "wrapper_123",
  "name": "Production Database",
  "type": "database",
  "startPeriod": null,
  "endPeriod": null
}

Error Responses

400
Bad Request
Failed to create resource. This can occur if:
  • The wrapper_id does not exist
  • A resource with the same identifier already exists
  • The request is malformed
{
  "detail": "Wrapper with ID 'wrapper_123' does not exist"
}
{
  "detail": "Resource with this identifier already exists"
}
{
  "detail": "Failed to create resource"
}
422
Validation Error
Invalid request body (missing required fields or incorrect types)
{
  "detail": [
    {
      "loc": ["body", "wrapper_id"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}
500
Internal Server Error
Database operation failed
{
  "detail": "Internal server error"
}

Build docs developers (and LLMs) love