> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Restart Service

> Restart a service (stop if running, then start). Returns streaming NDJSON with stop and start progress.



## OpenAPI

````yaml /sprites/api/openapi.json post /v1/sprites/{name}/services/{service_name}/restart
openapi: 3.1.0
info:
  title: Sprites API
  version: 0.1.12
  x-sprite-env-version: v0.0.1-rc48
servers:
  - url: https://api.sprites.dev
security: []
paths:
  /v1/sprites/{name}/services/{service_name}/restart:
    post:
      tags:
        - Services
      summary: Restart Service
      description: >-
        Restart a service (stop if running, then start). Returns streaming
        NDJSON with stop and start progress.
      operationId: sprite_env_restart__service
      parameters:
        - in: path
          name: name
          required: true
          schema:
            type: string
        - in: path
          name: service_name
          required: true
          schema:
            type: string
        - description: 'Time to monitor logs after starting (default: `5s`)'
          in: query
          name: duration
          required: false
          schema:
            description: 'Time to monitor logs after starting (default: `5s`)'
            type: integer
      responses:
        '200':
          content:
            application/x-ndjson:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ServiceLogStoppingEvent'
                  - $ref: '#/components/schemas/ServiceLogStoppedEvent'
                  - $ref: '#/components/schemas/ServiceLogStdoutEvent'
                  - $ref: '#/components/schemas/ServiceLogStderrEvent'
                  - $ref: '#/components/schemas/ServiceLogExitEvent'
                  - $ref: '#/components/schemas/ServiceLogErrorEvent'
                  - $ref: '#/components/schemas/ServiceLogCompleteEvent'
                  - $ref: '#/components/schemas/ServiceLogStartedEvent'
          description: Success - Streaming NDJSON response
        '404':
          description: Not Found - Resource not found
        '500':
          description: Internal Server Error
      security:
        - bearerAuth: []
components:
  schemas:
    ServiceLogStoppingEvent:
      example:
        timestamp: 1767609000000
        type: stopping
      properties:
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: stopping
          type: string
      required:
        - type
        - timestamp
      type: object
    ServiceLogStoppedEvent:
      example:
        exit_code: 0
        timestamp: 1767609000000
        type: stopped
      properties:
        exit_code:
          description: Process exit code
          type: integer
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: stopped
          type: string
      required:
        - type
        - exit_code
        - timestamp
      type: object
    ServiceLogStdoutEvent:
      example:
        data: |
          Server listening on port 3000
        timestamp: 1767609000000
        type: stdout
      properties:
        data:
          description: Log line content
          type: string
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: stdout
          type: string
      required:
        - type
        - data
        - timestamp
      type: object
    ServiceLogStderrEvent:
      example:
        data: |
          Warning: deprecated API usage
        timestamp: 1767609000000
        type: stderr
      properties:
        data:
          description: Log line content
          type: string
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: stderr
          type: string
      required:
        - type
        - data
        - timestamp
      type: object
    ServiceLogExitEvent:
      example:
        exit_code: 0
        timestamp: 1767609000000
        type: exit
      properties:
        exit_code:
          description: Process exit code
          type: integer
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: exit
          type: string
      required:
        - type
        - exit_code
        - timestamp
      type: object
    ServiceLogErrorEvent:
      example:
        data: 'Failed to start service: command not found'
        timestamp: 1767609000000
        type: error
      properties:
        data:
          description: Error message
          type: string
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: error
          type: string
      required:
        - type
        - data
        - timestamp
      type: object
    ServiceLogCompleteEvent:
      example:
        log_files:
          combined: /.sprite/logs/services/webapp.log
          stderr: /.sprite/logs/services/webapp.log
          stdout: /.sprite/logs/services/webapp.log
        timestamp: 1767609000000
        type: complete
      properties:
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: complete
          type: string
      required:
        - type
        - timestamp
      type: object
    ServiceLogStartedEvent:
      example:
        timestamp: 1767609000000
        type: started
      properties:
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: started
          type: string
      required:
        - type
        - timestamp
      type: object
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````