Create Or Update Service
PUT {{gateway}}/services/:serviceNameOrId
Create Or Update Service konghq
- Inserts (or replaces) the Service under the requested resource with the definition specified in the body. The Service will be identified via the name or id attribute.
- When the name or id attribute has the structure of a UUID, the Service being inserted/replaced will be identified by its id. Otherwise it will be identified by its name.
- When creating a new Service without specifying id (neither in the URL nor in the body), then it will be auto-generated.
- Notice that specifying a name in the URL and a different one in the request body is not allowed.
Attributes | Mandatory | Type | Description |
---|
service name or id | required | path | The unique identifier or the name of the Service to update. |
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=. With JSON, use “"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", "name"=>"httpbin-api", "retries"=>5, "protocol"=>"https", "port"=>443, "path"=>"/", "connect_timeout"=>60000, "write_timeout"=>60000, "read_timeout"=>60000, "tags"=>nil, "client_certificate"=>nil}
Key | Datatype | Required | Description |
---|
Content-Type | string | | |
RESPONSES
status: OK
{"host":"httpbin.org","created_at":1583630747,"connect_timeout":60000,"id":"c8b8f724-7e73-4df6-b1a8-8df19642d388","protocol":"https","name":"httpbin-api","read_timeout":60000,"port":443,"path":"/","updated_at":1583630747,"retries":5,"write_timeout":60000,"tags":null,"client_certificate":null}