# Services

Service management endpoints

## GET /services

> List all services

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Services","description":"Service management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}},"schemas":{"Service":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"user_id":{"type":"integer"},"is_premium":{"type":"boolean"},"keyless_mode":{"type":"boolean"},"keyless_weekdays":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"description":"Weekdays when keyless mode is active (Mon=0, Tue=1, ..., Sun=6). Empty array means weekday-based keyless is disabled.","default":[]},"slug":{"type":"string","nullable":true},"execution_count":{"type":"integer","minimum":0,"description":"Included only when include_execution_count=true is passed to the services endpoint. Cached per service in Redis for up to 5 minutes."},"created_at":{"type":"string","format":"date-time"}}}}},"paths":{"/services":{"get":{"summary":"List all services","tags":["Services"],"parameters":[{"name":"include_execution_count","in":"query","required":false,"schema":{"type":"boolean","default":false},"description":"Include execution_count for each service, counted from lua_script_access_logs through lua_scripts.service_id. Values are cached per service in Redis for up to 5 minutes."}],"responses":{"200":{"description":"List of services","content":{"application/json":{"schema":{"type":"object","properties":{"services":{"type":"array","items":{"$ref":"#/components/schemas/Service"}}}}}}},"401":{"description":"Unauthorized"},"429":{"description":"Rate limit exceeded"}}}}}}
```

## POST /services

> Create a new service

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Services","description":"Service management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}},"schemas":{"Service":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"user_id":{"type":"integer"},"is_premium":{"type":"boolean"},"keyless_mode":{"type":"boolean"},"keyless_weekdays":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"description":"Weekdays when keyless mode is active (Mon=0, Tue=1, ..., Sun=6). Empty array means weekday-based keyless is disabled.","default":[]},"slug":{"type":"string","nullable":true},"execution_count":{"type":"integer","minimum":0,"description":"Included only when include_execution_count=true is passed to the services endpoint. Cached per service in Redis for up to 5 minutes."},"created_at":{"type":"string","format":"date-time"}}}}},"paths":{"/services":{"post":{"summary":"Create a new service","tags":["Services"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":1,"maxLength":100},"description":{"type":"string","maxLength":500},"is_premium":{"type":"boolean","default":false},"slug":{"type":"string","minLength":3,"maxLength":50,"pattern":"^[a-zA-Z0-9-_]+$","description":"URL-friendly identifier"},"keyless_mode":{"type":"boolean","default":false},"keyless_weekdays":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"description":"Weekdays when keyless mode is active (Mon=0, Tue=1, ..., Sun=6)","default":[]}}}}}},"responses":{"201":{"description":"Service created","content":{"application/json":{"schema":{"type":"object","properties":{"service":{"$ref":"#/components/schemas/Service"}}}}}},"400":{"description":"Validation error"},"401":{"description":"Unauthorized"}}}}}}
```

## GET /services/{serviceId}

> Get service details

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Services","description":"Service management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}},"schemas":{"Service":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"user_id":{"type":"integer"},"is_premium":{"type":"boolean"},"keyless_mode":{"type":"boolean"},"keyless_weekdays":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"description":"Weekdays when keyless mode is active (Mon=0, Tue=1, ..., Sun=6). Empty array means weekday-based keyless is disabled.","default":[]},"slug":{"type":"string","nullable":true},"execution_count":{"type":"integer","minimum":0,"description":"Included only when include_execution_count=true is passed to the services endpoint. Cached per service in Redis for up to 5 minutes."},"created_at":{"type":"string","format":"date-time"}}}}},"paths":{"/services/{serviceId}":{"get":{"summary":"Get service details","tags":["Services"],"parameters":[{"name":"include_execution_count","in":"query","required":false,"schema":{"type":"boolean","default":false},"description":"Include execution_count for this service, counted from lua_script_access_logs through lua_scripts.service_id. Value is cached per service in Redis for up to 5 minutes."}],"responses":{"200":{"description":"Service details","content":{"application/json":{"schema":{"type":"object","properties":{"service":{"$ref":"#/components/schemas/Service"}}}}}},"404":{"description":"Service not found"}}}}}}
```

## PUT /services/{serviceId}

> Update service

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Services","description":"Service management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}}},"paths":{"/services/{serviceId}":{"put":{"summary":"Update service","tags":["Services"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"description":{"type":"string","maxLength":500},"is_premium":{"type":"boolean"},"slug":{"type":"string","minLength":3,"maxLength":50,"pattern":"^[a-zA-Z0-9-_]+$"},"keyless_mode":{"type":"boolean"},"keyless_weekdays":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"description":"Weekdays when keyless mode is active (Mon=0, Tue=1, ..., Sun=6)"}}}}}},"responses":{"200":{"description":"Service updated"},"404":{"description":"Service not found"}}}}}}
```

## DELETE /services/{serviceId}

> Delete service

```json
{"openapi":"3.0.3","info":{"title":"Junkie Key System REST API v2","version":"2.0.0"},"tags":[{"name":"Services","description":"Service management endpoints"}],"servers":[{"url":"https://api.jnkie.com/api/v2","description":"Production server"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"API Key with rest-api:* scope"}}},"paths":{"/services/{serviceId}":{"delete":{"summary":"Delete service","tags":["Services"],"responses":{"200":{"description":"Service deleted"},"404":{"description":"Service not found"}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.jnkie.com/rest-api/services.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
