Welcome to our new docs! Please keep in mind we are still working on making everything is as accurate as possible. Join us on discord and ask us questions if you are unsure.
DezerX Spartan Logo
Services

Create Service

Creates a new service for a user. Services can be created from existing products or as custom services with custom pricing and specifications.

POST
/services
AuthorizationBearer <token>

Bearer token authentication

In: header

user_idinteger
service_typestring
Value in"product"
product_idinteger
due_date?string
Formatdate
notes?string
user_idinteger
service_typestring
Value in"custom"
service_namestring
pricenumber
Formatdecimal
billing_cyclestring
Value in"monthly" | "quarterly" | "semi-annually" | "annually" | "biennially" | "triennially" | "one-time"
category_idinteger
due_date?string
Formatdate
notes?string
custom_fields?array<CustomField>
custom_buttons?array<CustomButton>

Response Body

curl -X POST "https://api.example.com/api/application/services" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": 123,
    "service_type": "product",
    "product_id": 456,
    "due_date": "2024-02-15",
    "notes": "VPS for client project"
  }'
{
  "success": true,
  "message": "Service created successfully",
  "data": {
    "id": 789,
    "owner_id": 123,
    "product_id": 456,
    "category_id": 1,
    "service_name": "VPS Hosting",
    "price": "19.99",
    "billing_cycle": "monthly",
    "status": "pending",
    "due_date": "2024-02-15",
    "notes": "VPS for client project",
    "custom_fields": {
      "custom_fields": [
        {
          "label": "Server Location",
          "value": "US East"
        }
      ],
      "custom_buttons": [
        {
          "label": "Restart Server",
          "action": "restart"
        }
      ]
    },
    "module": "PterodactylService",
    "created_at": "2024-01-15T10:30:00.000000Z",
    "updated_at": "2024-01-15T10:30:00.000000Z",
    "owner": {
      "id": 123,
      "name": "John Doe",
      "email": "john@example.com"
    },
    "product": {
      "id": 456,
      "name": "VPS Hosting"
    },
    "category": {
      "id": 1,
      "name": "Hosting"
    }
  }
}
{
  "error": "Unauthorized",
  "message": "Bearer token required"
}
{
  "error": "Forbidden",
  "message": "Insufficient permissions for this action"
}

{
  "success": false,
  "message": "Validation failed",
  "errors": {
    "user_id": [
      "The user id field is required."
    ],
    "service_type": [
      "The service type field is required."
    ],
    "product_id": [
      "The product id field is required."
    ]
  }
}

{
  "success": false,
  "message": "Error creating service: Database connection failed"
}