Create Service
POST {{gateway}}/services
Create Service konghq
- 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 for a detailed explanation of how Kong proxies traffic.
Request Body
Attributes | Mandatory | Description |
---|---|---|
name | optional | The Service name |
retries | optional | The number of retries to execute upon failure to proxy. Defaults to 5 |
protocol | required | The protocol used to communicate with the upstream. Accepted values are: "grpc", "grpcs", "http", "https", "tcp", "tls". Defaults to "http" |
host | required | The host of the upstream server |
port | required | The upstream server port. Defaults to 80 |
path | optional | The path to be used in requests to the upstream server. |
connect_timeout | optional | The timeout in milliseconds for establishing a connection to the upstream server. Defaults to 60000. |
write_timeout | optional | The timeout in milliseconds between two successive write operations for transmitting a request to the upstream server. Defaults to 60000. |
read_timeout | optional | The timeout in milliseconds between two successive read operations for transmitting a request to the upstream server. Defaults to 60000. |
tags | optional | An optional set of strings associated with the Service, for grouping and filtering. |
client_certificate | optional | Certificate to be used as client certificate while TLS handshaking to the upstream server. With form-encoded, the notation is client_certificate.id= |
url | required | Shorthand attribute to set protocol, host, port and path at once. This attribute is write-only (the Admin API never “returns” the url). |
Request Body
{"host"=>"httpbin.org", "connect_timeout"=>60000, "protocol"=>"https", "name"=>"httpbin-api", "read_timeout"=>60000, "port"=>443, "path"=>"/", "retries"=>5, "write_timeout"=>60000, "tags"=>nil, "client_certificate"=>nil}
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
Content-Type | string |
RESPONSES
status: Created
{"host":"httpbin.org","created_at":1584064654,"connect_timeout":60000,"id":"0022319a-a0b7-49d9-9eba-f2794f461de8","protocol":"https","name":"httpbin-api","read_timeout":60000,"port":443,"path":"/","updated_at":1584064654,"retries":5,"write_timeout":60000,"tags":null,"client_certificate":null}