Services

Create a new Service

Changed on

Create a new Service

post/{workspace}/services

Request

  • Base URL
    http://localhost:8001
  • Auth
    API key in header Kong-Admin-Token

Path parameters

workspace, string required
Example:team-payments

The name of the workspace

Request body

Service required

Service entities, as the name implies, are abstractions of each of your own upstream services. Examples of Services would be a data transformation microservice, a billing API, etc. The main attribute of a Service is its URL (where Kong should proxy traffic to), which can be set as a single string or by specifying its protocol, host, port and path individually. Services are associated to Routes (a Service can have many Routes associated with it). Routes are entry-points in Kong and define rules to match client requests. Once a Route is matched, Kong proxies the request to its associated Service. See the [Proxy Reference][proxy-reference] for a detailed explanation of how Kong proxies traffic.

ca_certificates, string[] nullable

Array of CA Certificate object UUIDs that are used to build the trust store while verifying upstream server's TLS certificate. If set to null when Nginx default is respected. If default CA list in Nginx are not specified and TLS verification is enabled, then handshake with upstream server will always fail (because no CA are trusted).

client_certificate, object nullable

Certificate to be used as client certificate while TLS handshaking to the upstream server.

connect_timeout, integer nullable

The timeout in milliseconds for establishing a connection to the upstream server.

created_at, integer nullable

Unix epoch when the resource was created.

enabled, boolean nullable

Whether the Service is active. If set to false, the proxy behavior will be as if any routes attached to it do not exist (404). Default: true.

host, string required

The host of the upstream server. Note that the host value is case sensitive.

id, string nullable

A string representing a UUID (universally unique identifier).

name, string nullable

The Service name.

path, string nullable

The path to be used in requests to the upstream server.

port, integer nullable

The upstream server port.

protocol, 'grpc' | 'grpcs' | 'http' | 'https' | 'tcp' | 'tls' | 'tls_passthrough' | 'udp' | 'ws' | 'wss' nullable

The protocol used to communicate with the upstream.

read_timeout, integer nullable

The timeout in milliseconds between two successive read operations for transmitting a request to the upstream server.

retries, integer nullable

The number of retries to execute upon failure to proxy.

tags, string[] nullable

An optional set of strings associated with the Service for grouping and filtering.

tls_sans, object nullable

Additional Subject Alternative Names that can be matched on Upstream server's TLS certificate (in addition to host).

tls_verify, boolean nullable

Whether to enable verification of upstream server TLS certificate. If set to null, then the Nginx default is respected.

tls_verify_depth, integer nullable

Maximum depth of chain while verifying Upstream server's TLS certificate. If set to null, then the Nginx default is respected.

updated_at, integer nullable

Unix epoch when the resource was last updated.

url, string nullable

Helper field to set protocol, host, port and path using a URL. This field is write-only and is not returned in responses.

write_timeout, integer nullable

The timeout in milliseconds between two successive write operations for transmitting a request to the upstream server.

Example request

{
  "host": "example.internal",
  "id": "49fd316e-c457-481c-9fc7-8079153e4f3c",
  "name": "example-service",
  "path": "/",
  "port": 80,
  "protocol": "http"
}

Response

Successfully created Service

Service required

Service entities, as the name implies, are abstractions of each of your own upstream services. Examples of Services would be a data transformation microservice, a billing API, etc. The main attribute of a Service is its URL (where Kong should proxy traffic to), which can be set as a single string or by specifying its protocol, host, port and path individually. Services are associated to Routes (a Service can have many Routes associated with it). Routes are entry-points in Kong and define rules to match client requests. Once a Route is matched, Kong proxies the request to its associated Service. See the [Proxy Reference][proxy-reference] for a detailed explanation of how Kong proxies traffic.

ca_certificates, string[] nullable

Array of CA Certificate object UUIDs that are used to build the trust store while verifying upstream server's TLS certificate. If set to null when Nginx default is respected. If default CA list in Nginx are not specified and TLS verification is enabled, then handshake with upstream server will always fail (because no CA are trusted).

client_certificate, object nullable

Certificate to be used as client certificate while TLS handshaking to the upstream server.

connect_timeout, integer nullable

The timeout in milliseconds for establishing a connection to the upstream server.

created_at, integer nullable

Unix epoch when the resource was created.

enabled, boolean nullable

Whether the Service is active. If set to false, the proxy behavior will be as if any routes attached to it do not exist (404). Default: true.

host, string required

The host of the upstream server. Note that the host value is case sensitive.

id, string nullable

A string representing a UUID (universally unique identifier).

name, string nullable

The Service name.

path, string nullable

The path to be used in requests to the upstream server.

port, integer nullable

The upstream server port.

protocol, 'grpc' | 'grpcs' | 'http' | 'https' | 'tcp' | 'tls' | 'tls_passthrough' | 'udp' | 'ws' | 'wss' nullable

The protocol used to communicate with the upstream.

read_timeout, integer nullable

The timeout in milliseconds between two successive read operations for transmitting a request to the upstream server.

retries, integer nullable

The number of retries to execute upon failure to proxy.

tags, string[] nullable

An optional set of strings associated with the Service for grouping and filtering.

tls_sans, object nullable

Additional Subject Alternative Names that can be matched on Upstream server's TLS certificate (in addition to host).

tls_verify, boolean nullable

Whether to enable verification of upstream server TLS certificate. If set to null, then the Nginx default is respected.

tls_verify_depth, integer nullable

Maximum depth of chain while verifying Upstream server's TLS certificate. If set to null, then the Nginx default is respected.

updated_at, integer nullable

Unix epoch when the resource was last updated.

url, string nullable

Helper field to set protocol, host, port and path using a URL. This field is write-only and is not returned in responses.

write_timeout, integer nullable

The timeout in milliseconds between two successive write operations for transmitting a request to the upstream server.

Example response

{
  "host": "example.internal",
  "id": "49fd316e-c457-481c-9fc7-8079153e4f3c",
  "name": "example-service",
  "path": "/",
  "port": 80,
  "protocol": "http"
}

Changes