Skip to main content
Version: 1.X

Open API Guide

Configuration Management​

Get configurations​

Description​

This API is used to get configurations in Nacos.

Request type​

GET

Request URL​

/nacos/v1/cs/configs

Request parameters​

NameTypeRequiredDescription
tenantstringNoTenant information. It corresponds to the Namespace ID field in Nacos.
dataIdstringYesConfiguration ID
groupstringYesConfiguration group

Return parameters​

Parameter typeDescription
StringConfiguration value

Error codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Example​

  • Request example

    curl -X GET 'http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.example&group=com.alibaba.nacos'

  • Return example

    contentTest

Listen for configurations​

Description​

This API is used to listen for configurations in Nacos to capture configuration changes. In case of any configuration changes, you can use the Get Configurations API to obtain the latest value of the configuration and dynamically refresh the local cache.

A listener is registered using an asynchronous servlet. The nature of registering a listener is to compare the configuration value and the MD5 value of it with that of the backend. If the values differ, the inconsistent configuration is returned immediately. Otherwise, an empty string is returned after 30 seconds.

Request type​

POST

Request URL​

/nacos/v1/cs/configs/listener

Request parameters​

Name
Type
Required
Description
Listening-Configs
string
No
A request to listen for data packets.
Format : dataId^group^2contentMD5^tenant^1 or dataId^group^2contentMD5^1.
  • dataId : Configuration ID
  • group : Configuration group
  • contentMD5 : The MD5 value of the configuration
  • tenant : Tenant information. It corresponds to the Namespace field in Nacos (not must)
Listening-Configs
string
Yes
A request to listen for data packets.
tenant
string
Yes
A packet field indicating tenant information. It corresponds to the Namespace field in Nacos.
dataId
string
Yes
A packet field indicating the configuration ID.
group
string
Yes
A packet field indicating the configuration group.
contentMD5
string
Yes
A packet field indicating the MD5 value of the configuration.

Header parameters​

NameTypeRequiredDescription
Long-Pulling-TimeoutstringYesThe timeout for long polling is 30s. Enter 30,000 here.

Parameter description​

  • A delimiter to separate fields within a configuration: ^2 = Character.toString((char) 2, The url encoded value is %02
  • A delimiter to separate configurations: ^1 = Character.toString((char) 1), The url encoded value is %01
  • contentMD5: MD5(content). This is an empty string because the first local cache is empty.

Return parameters​

Parameter typeDescription
StringConfiguration value

Error codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundClient error, not found
500Internal Server ErrorInternal server error
200OKNormal

Example​

  • Request example
http://serverIp:8848/nacos/v1/cs/configs/listener

POST request body data:

Listening-Configs=dataId%02group%02contentMD5%02tenant%01

  • Return example
In case of any configuration changes,

dataId%02group%02tenant%01

Otherwise, an empty string is returned.

Publish configuration​

Description​

It publishes configurations in Nacos.

Request Type​

POST

Request URL​

/nacos/v1/cs/configs

Request parameters​

NameTypeRequiredDescription
tenantStringNoThe tenant, corresponding to the namespace ID field of Nacos
dataIdStringYesConfiguration ID
groupStringYesConfiguration group
contentStringYesConfiguration content
typeStringNoConfiguration type

Response parameters​

ParametertypeDescription
booleanIf the publishing is successful

Error code​

Error codeDescriptionMeaning
400Bad RequestSyntax error in client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Example​

Request example​

curl -X POST 'http://127.0.0.1:8848/nacos/v1/cs/configs' -d 'dataId=nacos.example&group=com.alibaba.nacos&content=contentTest'

Response example​

true

Delete configuration​

Description​

It deletes configurations in Nacos.

Request Type​

DELETE

Request URL​

/nacos/v1/cs/configs

Request parameters​

NameTypeRequiredDescription
tenantStringNoThe tenant, corresponding to the namespace ID field of Nacos
dataIdStringYesConfiguration ID
groupStringYesConfiguration group

Response parameters​

Parameter typeDescription
booleanIf the deletion is successful

Error code​

Error codeDescriptionMeaning
400Bad RequestSyntax error in client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Example​

Request example​

curl -X DELETE 'http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.example&group=com.alibaba.nacos'

Response example​

true

Query list of history configuration​

Description​

Query list of history configuration.

Request Type​

GET

Request URL​

/nacos/v1/cs/history?search=accurate

Request parameters​

NameTypeRequiredDescription
tenantstringNoTenant information. It corresponds to the Namespace ID field in Nacos.
dataIdstringYesConfiguration ID
groupstringYesConfiguration group
pageNointegernopage number
pageSizeintegernopage size (default:100, max:500)

Error code​

Error codeDescriptionMeaning
400Bad RequestSyntax error in client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Example​

Request example​

curl -X GET 'http://127.0.0.1:8848/nacos/v1/cs/history?search=accurate&dataId=nacos.example&group=com.alibaba.nacos'

Response example​

{
"totalCount": 1,
"pageNumber": 1,
"pagesAvailable": 1,
"pageItems": [
{
"id": "203",
"lastId": -1,
"dataId": "nacos.example",
"group": "com.alibaba.nacos",
"tenant": "",
"appName": "",
"md5": null,
"content": null,
"srcIp": "0:0:0:0:0:0:0:1",
"srcUser": null,
"opType": "I ",
"createdTime": "2010-05-04T16:00:00.000+0000",
"lastModifiedTime": "2020-12-05T01:48:03.380+0000"
}
]
}

Query the history details of the configuration​

Description​

Query the history details of the configuration

Request Type​

GET

Request URL​

/nacos/v1/cs/history

Request Parameters​

NameTypeRequiredDescription
nidIntegerYeshistory config info ID
tenantstringNoTenant information. It corresponds to the Namespace ID field in Nacos. (Since 2.0.3)
dataIdstringYesConfiguration ID (Since 2.0.3)
groupstringYesConfiguration group (Since 2.0.3)

Note: From version 2.0.3, this interface need add three parameter, include tenant, dataId and group, tenant can not be provided.

Error Code​

Error codeDescriptionMeaning
400Bad RequestSyntax error in client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Example​

Request example​

curl -X GET 'http://127.0.0.1:8848/nacos/v1/cs/history?nid=203&tenant=&dataId=nacos.example&group=com.alibaba.nacos'

Response example​

{
"id": "203",
"lastId": -1,
"dataId": "nacos.example",
"group": "com.alibaba.nacos",
"tenant": "",
"appName": "",
"md5": "9f67e6977b100e00cab385a75597db58",
"content": "contentTest",
"srcIp": "0:0:0:0:0:0:0:1",
"srcUser": null,
"opType": "I ",
"createdTime": "2010-05-04T16:00:00.000+0000",
"lastModifiedTime": "2020-12-05T01:48:03.380+0000"
}

Query the previous version of the configuration​

Description​

Query the previous version of the configuration.(Since 1.4.0)

Request Type​

GET

Request URL​

/nacos/v1/cs/history/previous

Request Paramters​

NameTypeRequiredDescription
idIntegerYesconfiguration unique id
tenantstringNoTenant information. It corresponds to the Namespace ID field in Nacos. (Since 2.0.3)
dataIdstringYesConfiguration ID (Since 2.0.3)
groupstringYesConfiguration group (Since 2.0.3)

Note: From version 2.0.3, this interface need add three parameter, include tenant, dataId and group, tenant can not be provided.

Error Code​

Error codeDescriptionMeaning
400Bad RequestSyntax error in client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Example​

Request example​

curl -X GET 'http://127.0.0.1:8848/nacos/v1/cs/history/previous?id=309135486247505920&tenant=&dataId=nacos.example&group=com.alibaba.nacos'

Response example​

{
"id": "203",
"lastId": -1,
"dataId": "nacos.example",
"group": "com.alibaba.nacos",
"tenant": "",
"appName": "",
"md5": "9f67e6977b100e00cab385a75597db58",
"content": "contentTest",
"srcIp": "0:0:0:0:0:0:0:1",
"srcUser": null,
"opType": "I ",
"createdTime": "2010-05-04T16:00:00.000+0000",
"lastModifiedTime": "2020-12-05T01:48:03.380+0000"
}

Service Discovery​

Register instance​

Description​

Register an instance to service.

Request Type​

POST

Request Path​

/nacos/v1/ns/instance

Request Parameters​

NameTypeRequiredDescription
ipStringyesIP of instance
portintyesPort of instance
namespaceIdStringnoID of namespace
weightdoublenoWeight
enabledbooleannoenabled or not
healthybooleannohealthy or not
metadataStringnoextended information
clusterNameStringnocluster name
serviceNameStringyesservice name
groupNameStringnogroup name
ephemeralbooleannoif instance is ephemeral

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance?port=8848&healthy=true&ip=11.11.11.11&weight=1.0&serviceName=nacos.test.3&encoding=GBK&namespaceId=n1'

Response Example​

ok

Deregister instance​

Description​

Delete instance from service.

Request Type​

DELETE

Request Path​

/nacos/v1/ns/instance

Request Parameters​

NameTypeRequiredDescription
serviceNameStringyesService name
groupNameStringnogroup name
ephemeralbooleannoif instance is ephemeral
ipStringyesIP of instance
portintyesPort of instance
clusterNameStringnoCluster name
namespaceIdStringnoID of namespace

error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X DELETE '127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.test.1&ip=1.1.1.1&port=8888&clusterName=TEST1'

Response Example​

ok

Modify instance​

Description​

Modify an instance of service.

Attension:After Nacos2.0 version, the metadata updated through this interface has a higher priority and has the ability to remember. After the instance removed, it will still exist for a period of time. If the instance is re-registered during this period, the metadata will still be Effective. You can modify the memory time through nacos.naming.clean.expired-metadata.expired-time and nacos.naming.clean.expired-metadata.interval

Request Type​

PUT

Request Path​

/nacos/v1/ns/instance

Request Parameters​

NameTypeRequiredDescription
serviceNameStringyesService name
groupNameStringnogroup name
ephemeralbooleannoif instance is ephemeral
ipStringyesIP of instance
portintyesPort of instance
clusterNameStringnoCluster name
namespaceIdStringnoID of namespace
weightdoublenoWeight
enabledbooleannoIf enabled
metadataJSONnoExtended information

error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X PUT '127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.test.1&ip=1.1.1.1&port=8888&clusterName=TEST1&weight=8&metadata={}'

Response Example​

ok

Query instances​

Description​

Query instance list of service.

Request Type​

GET

Request Path​

/nacos/v1/ns/instance/list

Request Parameters​

NameTypeRequiredDescription
serviceNameStringyesService name
groupNameStringnogroup name
namespaceIdStringnoID of namespace
clustersString, splited by commanoCluster name
healthyOnlybooleanno, default value is falseReturn healthy instance or not

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X GET '127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=nacos.test.1'

Response Example​

{
"name": "DEFAULT_GROUP@@nacos.test.1",
"groupName": "DEFAULT_GROUP",
"clusters": "",
"cacheMillis": 10000,
"hosts": [
{
"instanceId": "10.10.10.10#8888#DEFAULT#DEFAULT_GROUP@@nacos.test.1",
"ip": "10.10.10.10",
"port": 8888,
"weight": 1,
"healthy": false,
"enabled": true,
"ephemeral": false,
"clusterName": "DEFAULT",
"serviceName": "DEFAULT_GROUP@@nacos.test.1",
"metadata": { },
"instanceHeartBeatInterval": 5000,
"instanceIdGenerator": "simple",
"instanceHeartBeatTimeOut": 15000,
"ipDeleteTimeout": 30000
}
],
"lastRefTime": 1528787794594,
"checksum": "",
"allIPs": false,
"reachProtectionThreshold": false,
"valid": true
}

Query instance detail​

Description​

Query instance details of service.

Request Type​

GET

Request Path​

/nacos/v1/ns/instance

Request Parameters​

NameTypeRequiredDescription
namespaceIdStringnoID of namespace
serviceNameStringyesService name
groupNameStringnogroup name
ephemeralbooleannoif instance is ephemeral
ipStringyesIP of instance
portStringyesPort of instance
clusterStringnoCluster name

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X GET '127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.test.2&ip=10.10.10.10&port=8888&cluster=DEFAULT'

Response Example​

{
"metadata": {},
"instanceId": "10.10.10.10-8888-DEFAULT-nacos.test.2",
"port": 8888,
"service": "nacos.test.2",
"healthy": false,
"ip": "10.10.10.10",
"clusterName": "DEFAULT",
"weight": 1.0
}

Send instance beat​

Description​

Send instance beat

Request Type​

PUT

Request Path​

/nacos/v1/ns/instance/beat

Request Parameters​

NameTypeRequiredDescription
serviceNameStringyesservice name
ipStringyesip of instance
portintyesport of instance
namespaceIdStringnoID of namespace
groupNameStringnogroup name
beatStringyesbeat content

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X PUT '127.0.0.1:8848/nacos/v1/ns/instance/beat?serviceName=nacos.test.2&beat=%7b%22cluster%22%3a%22c1%22%2c%22ip%22%3a%22127.0.0.1%22%2c%22metadata%22%3a%7b%7d%2c%22port%22%3a8080%2c%22scheduled%22%3atrue%2c%22serviceName%22%3a%22jinhan0Fx4s.173TL.net%22%2c%22weight%22%3a1%7d'

Response Example​

ok

Create service​

Description​

Create service

Request Type​

POST

Request Path​

/nacos/v1/ns/service

Request Parameters​

NameTypeRequiredDescription
serviceNameStringyesservice name
groupNameStringnogroup name
namespaceIdStringnonamespace id
protectThresholdfloatnoset value from 0 to 1, default 0
metadataStringnometadata of service
selectorJSONnovisit strategy

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X POST '127.0.0.1:8848/nacos/v1/ns/service?serviceName=nacos.test.2&metadata=k1%3dv1'

Response Example​

ok

Delete service​

Description​

Delete a service, only permitted when instance count is 0.

Request Type​

DELETE

Request Path​

/nacos/v1/ns/service

Request Parameters​

NameTypeRequiredDescription
serviceNameStringyesservice name
groupNameStringnogroup name
namespaceIdStringnonamespace id

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X DELETE '127.0.0.1:8848/nacos/v1/ns/service?serviceName=nacos.test.2'

Response Example​

ok

Update service​

Description​

Update a service

Request Type​

PUT

Request Path​

/nacos/v1/ns/service

Request Parameters​

NameTypeRequiredDescription
serviceNameStringyesservice name
groupNameStringnogroup name
namespaceIdStringnonamespace id
protectThresholdfloatnoset value from 0 to 1, default 0
metadataStringnometadata of service
selectorJSONnovisit strategy

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X PUT '127.0.0.1:8848/nacos/v1/ns/service?serviceName=nacos.test.2&metadata=k1%3dv1'

Response Example​

ok

Query service​

Description​

Query a service

Request Type​

GET

Request Path​

/nacos/v1/ns/service

Request Parameters​

NameTypeRequiredDescription
serviceNameStringyesservice name
groupNameStringnogroup name
namespaceIdStringnonamespace id

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X GET '127.0.0.1:8848/nacos/v1/ns/service?serviceName=nacos.test.2'

Response Example​

{
metadata: { },
groupName: "DEFAULT_GROUP",
namespaceId: "public",
name: "nacos.test.2",
selector: {
type: "none"
},
protectThreshold: 0,
clusters: [
{
healthChecker: {
type: "TCP"
},
metadata: { },
name: "c1"
}
]
}

Query service list​

Description​

Query service list

Request Type​

GET

Request Path​

/nacos/v1/ns/service/list

Request Parameters​

NameTypeRequiredDescription
pageNointyescurrent page number
pageSizeintyespage size
groupNameStringnogroup name
namespaceIdStringnonamespace id

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X GET '127.0.0.1:8848/nacos/v1/ns/service/list?pageNo=1&pageSize=2'

Response Example​

{
"count":148,
"doms": [
"nacos.test.1",
"nacos.test.2"
]
}

Query system switches​

Description​

Query system switches

Request Type​

GET

Request Path​

/nacos/v1/ns/operator/switches

Request Parameters​

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X GET '127.0.0.1:8848/nacos/v1/ns/operator/switches'

Response Example​

{
name: "00-00---000-NACOS_SWITCH_DOMAIN-000---00-00",
masters: null,
adWeightMap: { },
defaultPushCacheMillis: 10000,
clientBeatInterval: 5000,
defaultCacheMillis: 3000,
distroThreshold: 0.7,
healthCheckEnabled: true,
distroEnabled: true,
enableStandalone: true,
pushEnabled: true,
checkTimes: 3,
httpHealthParams: {
max: 5000,
min: 500,
factor: 0.85
},
tcpHealthParams: {
max: 5000,
min: 1000,
factor: 0.75
},
mysqlHealthParams: {
max: 3000,
min: 2000,
factor: 0.65
},
incrementalList: [ ],
serverStatusSynchronizationPeriodMillis: 15000,
serviceStatusSynchronizationPeriodMillis: 5000,
disableAddIP: false,
sendBeatOnly: false,
limitedUrlMap: { },
distroServerExpiredMillis: 30000,
pushGoVersion: "0.1.0",
pushJavaVersion: "0.1.0",
pushPythonVersion: "0.4.3",
pushCVersion: "1.0.12",
enableAuthentication: false,
overriddenServerStatus: "UP",
defaultInstanceEphemeral: true,
healthCheckWhiteList: [ ],
checksum: null
}

Update system switch​

Description​

Update system switch

Request Type​

PUT

Request Path​

/nacos/v1/ns/operator/switches

Request Parameters​

NameTypeRequiredDescription
entryStringyesswitch name
valueStringyesswitch value
debugbooleannoif affect the local server, true means yes, false means no, default true

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X PUT '127.0.0.1:8848/nacos/v1/ns/operator/switches?entry=pushEnabled&value=false&debug=true'

Response Example​

ok

Query system metrics​

Description​

Query system metrics

Request Type​

GET

Request Path​

/nacos/v1/ns/operator/metrics

Request Parameters​

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X GET '127.0.0.1:8848/nacos/v1/ns/operator/metrics'

Response Example​

{
serviceCount: 336,
load: 0.09,
mem: 0.46210432,
responsibleServiceCount: 98,
instanceCount: 4,
cpu: 0.010242796,
status: "UP",
responsibleInstanceCount: 0
}

Query server list​

Description​

Query server list

Request Type​

GET

Request Path​

/nacos/v1/ns/operator/servers

Request Parameters​

NameTypeRequiredDescription
healthybooleannoif return healthy servers only

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X GET '127.0.0.1:8848/nacos/v1/ns/operator/servers'

Response Example​

{
servers: [
{
ip: "1.1.1.1",
servePort: 8848,
site: "unknown",
weight: 1,
adWeight: 0,
alive: false,
lastRefTime: 0,
lastRefTimeStr: null,
key: "1.1.1.1:8848"
},
{
ip: "1.1.1.2",
servePort: 8848,
site: "unknown",
weight: 1,
adWeight: 0,
alive: false,
lastRefTime: 0,
lastRefTimeStr: null,
key: "1.1.1.2:8848"
},
{
ip: "1.1.1.3",
servePort: 8848,
site: "unknown",
weight: 1,
adWeight: 0,
alive: false,
lastRefTime: 0,
lastRefTimeStr: null,
key: "1.1.1.3:8848"
}
]
}

Query the leader of current cluster​

Description​

Query the leader of current cluster

Request Type​

GET

Request Path​

/nacos/v1/ns/raft/leader

Request Parameters​

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X GET '127.0.0.1:8848/nacos/v1/ns/raft/leader'

Response Example​

{
leader: "{"heartbeatDueMs":2500,"ip":"1.1.1.1:8848","leaderDueMs":12853,"state":"LEADER","term":54202,"voteFor":"1.1.1.1:8848"}"
}

Update instance health status​

Description​

Update instance health status, only works when the cluster health checker is set to NONE.

Request Type​

PUT

Request Path​

/nacos/v1/ns/health/instance

Request Parameters​

NameTypeRequiredDescription
serviceNameStringyesservice name
groupNameStringnogroup name
namespaceIdStringnonamespace id
clusterNameStringnocluster name
ipStringyesip of instance
portintyesport of instance
healthybooleanyesif healthy

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X PUT 'http://127.0.0.1:8848/nacos/v1/ns/health/instance?port=8848&healthy=true&ip=11.11.11.11&serviceName=nacos.test.3&namespaceId=n1'

Response Example​

ok

Batch update instance metadata(Beta)​

Description​

Batch update instance metadata(Since 1.4)

Note: This API is a Beta API, later versions maybe modify or even delete. Please use it with caution.

Request Type​

PUT

Request Path​

/nacos/v1/ns/instance/metadata/batch

Request Parameters​

NameTypeRequiredDescription
namespaceIdStringyesID of namespace
serviceNameStringyesService name(group@@serviceName)
consistencyTypeStringnoinstance type (ephemeral/persist)
instancesJSONnoThe instances which need to update
metadataJSONyesMetadata

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Parameter description​

  • consistencyType: The priority higher than param instances, if config it, the param instances will be ignored. When when value equals 'ephemeral', all the ephemeral instances in serviceName will be updated. When when value equals 'persist', all the persist instances in serviceName will be updated. When other value, no instances will be updated.
  • instances: json array. To locate particular instances by (ip + port + ephemeral + cluster).

Request Example​

curl -X PUT 'http://localhost:8848/nacos/v1/ns/instance/metadata/batch' -d 'namespaceId=public&serviceName=xxxx@@xxxx&instances=[{"ip":"3.3.3.3","port": "8080","ephemeral":"true","clusterName":"xxxx-cluster"},{"ip":"2.2.2.2","port":"8080","ephemeral":"true","clusterName":"xxxx-cluster"}]&metadata={"age":"20","name":"cocolan"}' 
or
curl -X PUT 'http://localhost:8848/nacos/v1/ns/instance/metadata/batch' -d 'namespaceId=public&serviceName=xxxx@@xxxx&consistencyType=ephemeral&metadata={"age":"20","name":"cocolan"}'

Response Example​

{"updated":["2.2.2.2:8080:unknown:xxxx-cluster:ephemeral","3.3.3.3:8080:unknown:xxxx-cluster:ephemeral"]}

Batch delete instance metadata(Beta)​

Description​

Batch delete instance metadata(Since 1.4)

Note: This API is a Beta API, later versions maybe modify or even delete. Please use it with caution.

Request Type​

DELETE

Request Path​

/nacos/v1/ns/instance/metadata/batch

Request Parameters​

NameTypeRequiredDescription
namespaceIdStringyesID of namespace
serviceNameStringyesService name(group@@serviceName)
consistencyTypeStringnoinstance type (ephemeral/persist)
instancesJSONnoThe instances which need to update
metadataJSONyesMetadata

Error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Parameter description​

  • consistencyType: The priority higher than param instances, if config it, the param instances will be ignored. When when value equals 'ephemeral', all the ephemeral instances in serviceName will be updated. When when value equals 'persist', all the persist instances in serviceName will be updated. When other value, no instances will be updated.
  • instances: json array. To locate particular instances by (ip + port + ephemeral + cluster).

Request Example​

curl -X DELETE 'http://localhost:8848/nacos/v1/ns/instance/metadata/batch' -d 'namespaceId=public&serviceName=xxxx@@xxxx&instances=[{"ip":"3.3.3.3","port": "8080","ephemeral":"true","clusterName":"xxxx-cluster"},{"ip":"2.2.2.2","port":"8080","ephemeral":"true","clusterName":"xxxx-cluster"}]&metadata={"age":"20","name":"cocolan"}' 
or
curl -X DELETE 'http://localhost:8848/nacos/v1/ns/instance/metadata/batch' -d 'namespaceId=public&serviceName=xxxx@@xxxx&consistencyType=ephemeral&metadata={"age":"20","name":"cocolan"}'

Response Example​

{"updated":["2.2.2.2:8080:unknown:xxxx-cluster:ephemeral","3.3.3.3:8080:unknown:xxxx-cluster:ephemeral"]}

Namespace​

Get namespace​

Description​

This API is used to get namespaces in Nacos.

Request Type​

GET

Request Path​

/nacos/v1/ns/instance

Request Parameters​

None

error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X GET 'http://localhost:8848/nacos/v1/console/namespaces'

Response Example​

{"code":200,"message":null,"data":[{"namespace":"","namespaceShowName":"public","quota":200,"configCount":0,"type":0}]}

Create namespace​

Description​

Create namespace

Request Type​

POST

Request Path​

/nacos/v1/console/namespaces

Request Parameters​

NameTypeRequiredDescription
customNamespaceIdStringyesID of namespace
namespaceNameStringyesNamespace name
namespaceDescStringnoNamespace description

error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X POST 'http://localhost:8848/nacos/v1/console/namespaces' -d 'customNamespaceId=&namespaceName=dev&namespaceDesc='

Response Example​

true

Modify namespace​

Description​

Update namespace

Request Type​

PUT

Request Path​

/nacos/v1/console/namespaces

Request Parameters​

NameTypeRequiredDescription
namespaceStringyesID of namespace
namespaceShowNameStringyesNamespace name
namespaceDescStringyesNamespace description

error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X PUT 'http://localhost:8848/nacos/v1/console/namespaces' -d 'namespace=dev&namespaceShowName=开发环境2&namespaceDesc=只用于开发2'

Response Example​

true

Delete namespace​

Description​

It deletes namespace in Nacos.

Request Type​

DELETE

Request Path​

/nacos/v1/console/namespaces

Request Parameters​

NameTypeRequiredDescription
namespaceIdStringyesID of namespace

error Codes​

Error codeDescriptionMeaning
400Bad RequestSyntax error in the client request
403ForbiddenNo permission
404Not FoundNot found resource
500Internal Server ErrorInternal server error
200OKNormal

Request Example​

curl -X DELETE 'http://localhost:8848/nacos/v1/console/namespaces' -d 'namespaceId=dev'

Response Example​

true