기술 자료

Cloud Code Admin API

버전 v1

Cloud Code Admin API

버전 v1

Cloud Code Admin API

Overview

This is the API specification for the Unity Cloud Code Admin service that enables game developers to create and edit server-side code for their games.

Rate limits

The API has rate limiting in place. The endpoints are limited to 60 requests per second and 1000 requests per thirty minutes on a per-project and per-IP basis.
The API responds with a
429
HTTP status code if the rate limit is exceeded.
The API also responds with a
Retry-After
header to use in conjunction with a client's retry logic. The value is the number of seconds until the API accepts a request for the given project and IP.

Useful links

Download OpenAPI specification:

List scripts


Get a list of the Cloud Code scripts for a project environment
Authorizations
ServiceAccount (cloud_code.scripts.list)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.scripts.list

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

Query parameters for "{title}"

limit

integer
The number of scripts to return.
>= 1<= 500

after

string
No description
pattern: ^[a-zA-Z0-9-_]+$

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/scripts"

Response example

{ "results": [ { "name": "string", "type": "string", "language": "JS", "published": true, "lastPublishedDate": "2022-04-05T09:12:13Z", "lastPublishedVersion": 0 } ], "links": { "next": "string" }}

Create script


Create a Cloud Code script for a project environment
Authorizations
ServiceAccount (cloud_code.scripts.create)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.scripts.create

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

Request body for "{title}"

Media Type:
application/json

name

string
필수
Name of the script. Serves as a unique identifier.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9-_]+$

type

string
필수
The type of the script.

params

array[object]
The list of parameters which can be defined for a script.
minItems: 0maxItems: 10uniqueItems

name

string
필수
Name of the script parameter.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9-_]+$

type

string
기본: ANY
The type of the parameter.
enum: "STRING", "BOOLEAN", "NUMERIC", "JSON", "ANY"

required

boolean
A flag indicating if the parameter is required when running a Script.

code

string
The script code to be executed
maxLength: 131072

language

string
기본: JS
The language of the script.
enum: "JS"

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Content-Type: application/json" \ -d '{ "name": "string", "type": "string", "params": [], "code": "string", "language": "JS"}' \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/scripts"

Response example

{ "type": "string", "title": "string", "status": 0, "requestId": "6203fac6-6579-4a71-a659-e20655580408", "code": 0, "detail": "string", "instance": "string", "details": [ {} ]}

Get script


Get a Cloud Code script for a project environment
Authorizations
ServiceAccount (cloud_code.scripts.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.scripts.get

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

scriptName

string
필수
Name of the script.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9-_]+$

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/scripts/{scriptName}"

Response example

{ "name": "test-3", "type": "API", "language": "JS", "activeScript": { "code": "module.exports=async (cloudCode) =>{cloudCode.logger.info('this message confirms that the logging client is functional!'); return cloudCode.params.someThing;}", "params": [ { "name": "someThing", "type": "STRING", "required": true } ], "version": 2, "datePublished": "2021-07-23T16:08:35Z" }, "versions": [ { "code": "module.exports=async (cloudCode) =>{cloudCode.logger.info('this message confirms that the logging client is functional!'); return cloudCode.params.someThing;}", "params": [ { "name": "someThing", "type": "STRING", "required": true } ], "isDraft": true, "version": null, "dateUpdated": "2021-07-23T15:59:32Z" }, { "code": "module.exports=async (cloudCode) =>{cloudCode.logger.info('this message confirms that the logging client is functional!'); return cloudCode.params.someThing;}", "params": [ { "name": "someThing", "type": "STRING", "required": true } ], "isDraft": false, "version": 2, "dateUpdated": "2021-07-23T16:08:35Z", "dateCreated": "2021-07-23T16:08:35Z" }, { "code": "module.exports=async (cloudCode) =>{cloudCode.logger.info('this message confirms that the logging client is functional!'); return cloudCode.params.someThing;}", "params": [ { "name": "someThing", "type": "STRING", "required": true } ], "isDraft": false, "version": 1, "dateUpdated": "2021-07-23T15:59:58Z", "dateCreated": "2021-07-23T15:59:58Z" } ], "params": [ { "name": "someThing", "type": "STRING", "required": true } ]}

Update script


Update a Cloud Code script for a project environment
Authorizations
ServiceAccount (cloud_code.scripts.update)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.scripts.update

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

scriptName

string
필수
Name of the script.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9-_]+$

Request body for "{title}"

Media Type:
application/json

params

array[object]
The list of parameters which can be defined for a script.
minItems: 0maxItems: 10uniqueItems

name

string
필수
Name of the script parameter.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9-_]+$

type

string
기본: ANY
The type of the parameter.
enum: "STRING", "BOOLEAN", "NUMERIC", "JSON", "ANY"

required

boolean
A flag indicating if the parameter is required when running a Script.

code

string
The script code to be executed
maxLength: 131072

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X PATCH \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Content-Type: application/json" \ -d '{ "params": [], "code": "string"}' \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/scripts/{scriptName}"

Response example

{ "$ref": "#/components/examples/GatewayUnauthorizedErrorResponse"}

Delete script


Delete a Cloud Code script for a project environment.
Authorizations
ServiceAccount (cloud_code.scripts.delete)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.scripts.delete

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

scriptName

string
필수
Name of the script.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9-_]+$

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X DELETE \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/scripts/{scriptName}"

Response example

{ "$ref": "#/components/examples/GatewayUnauthorizedErrorResponse"}

Publish script


Publish a Cloud Code script for a project environment. You can't republish the active script, or publish a script with compiliaton errors.
Authorizations
ServiceAccount (cloud_code.scripts.publish)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.scripts.publish

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

scriptName

string
필수
Name of the script.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9-_]+$

Request body for "{title}"

Media Type:
application/json

version

integer
Version number to be published.

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Content-Type: application/json" \ -d '{ "version": 0}' \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/scripts/{scriptName}/publish"

Response example

{ "version": 0, "datePublished": "2022-04-05T09:12:13Z"}

List modules


Get a list of Cloud Code modules within a project environment.
This endpoint supports token-based pagination.

UGS CLI

You an also list modules through the UGS CLI with the list modules command.
Authorizations
ServiceAccount (cloud_code.modules.list)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.modules.list

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

Query parameters for "{title}"

limit

integer
The number of modules to return.
>= 1<= 50

after

string
Page token
pattern: ^[a-zA-Z0-9-_]+$

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/modules"

Response example

{ "results": [ { "name": "string", "language": "CS", "tags": {}, "signedDownloadURL": "string", "dateCreated": "2022-04-05T09:12:13Z", "dateModified": "2022-04-05T09:12:13Z" } ], "links": { "next": "string" }, "nextPageToken": "string"}

Create module


Create Cloud Code module metadata and assemblies within a project environment.
Creating, updating, or deleting a module is not instant as changes roll out gradually. This ensures that there are never any periods of downtime in which Cloud Code is not available to serve requests.

Size limits

  • A module cannot exceed the size of 10 MB.
  • The combined size of all modules in your project cannot exceed 128 MB.
  • You can't have more than 20 modules across all your environments.
Exceeding the individual module size limit results in a HTTP response with error code
429
. Exceeding the total number or size limits across all environments in your project result to a response with code
507
.

UGS CLI

You can also create a module through the UGS CLI with the deploy command.
Authorizations
ServiceAccount (cloud_code.modules.create)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.modules.create

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

Request body for "{title}"

Media Type:
multipart/form-data

name

string
필수
Name of a Cloud Code module.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9_]+$

language

string
기본: CS
필수
The language of a Cloud Code module. Currently, only
CS
(C#) is supported.
enum: "CS"

tags

object
A set of user-defined tags in the form of string key-value pairs.
Use these if you need to add additional metadata related to the module.
For example, if you want to automate deployment of modules with some synchronization mechanism, you can use user-defined tags for marking version or ownership to avoid conflicts.
maxProperties: 10

file

string
필수
ZIP archive file containing the module assemblies packaged for the linux-x64 runtime in ReadyToRun (R2R) format. For further detail, see Manual packaging.
binary

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X POST \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Content-Type: multipart/form-data" \ -d '{"name":"string","language":"CS","tags":{},"file":"string"}' \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/modules"

Response example

{ "dateCreated": "2022-04-05T09:12:13Z"}

Get module


Get useful information about a Cloud Code module within a project environment. This information does not include the compiled module package last uploaded when creating or updating a module.

UGS CLI

You can also get information about a module through the UGS CLI with the get module command.
Authorizations
ServiceAccount (cloud_code.modules.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.modules.get

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

moduleName

string
필수
Name of a Cloud Code module.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9_]+$

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/modules/{moduleName}"

Response example

{ "name": "string", "language": "CS", "tags": {}, "signedDownloadURL": "string", "dateCreated": "2022-04-05T09:12:13Z", "dateModified": "2022-04-05T09:12:13Z", "endpoints": { "endpoint1": { "parameters": { "name": "System.String", "age": "System.Int32" }, "returnType": "System.String" }, "endpoint2": { "parameters": { "name": "System.String", "age": "System.Int32" }, "returnType": "System.String" } }, "hasError": true, "errorMessage": "string"}

Delete module


Delete a Cloud Code module within a project environment.
Creating, updating, or deleting a module is not instant as changes roll out gradually. This ensures that there are never any periods of downtime in which Cloud Code is not available to serve requests.

UGS CLI

You can also delete a module through the UGS CLI with the delete module command.
Authorizations
ServiceAccount (cloud_code.modules.delete)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.modules.delete

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

moduleName

string
필수
Name of a Cloud Code module.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9_]+$

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X DELETE \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/modules/{moduleName}"

Response example

{ "$ref": "#/components/examples/ModuleNameMissingErrorResponse"}

Update module


Change Cloud Code module metadata and assemblies within a project environment.
Creating, updating, or deleting a module is not instant as changes roll out gradually. This ensures that there are never any periods of downtime in which Cloud Code is not available to serve requests.

Size limits

  • A module cannot exceed the size of 10 MB.
  • The combined size of all modules in your project cannot exceed 128 MB.
Exceeding the individual module size limit results in a HTTP response with error code
429
. Exceeding the total number limit across all environments in your project result to a response with code
507
.

UGS CLI

You can also update a module through the UGS CLI with the deploy command.
Authorizations
ServiceAccount (cloud_code.modules.update)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.modules.update

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

moduleName

string
필수
Name of a Cloud Code module.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9_]+$

Request body for "{title}"

Media Type:
multipart/form-data

tags

object
A set of user-defined tags in the form of string key-value pairs.
Use these if you need to add additional metadata related to the module.
For example, if you want to automate deployment of modules with some synchronization mechanism, you can use user-defined tags for marking version or ownership to avoid conflicts.
maxProperties: 10

file

string
ZIP archive file containing the module assemblies packaged for the linux-x64 runtime in ReadyToRun (R2R) format. For further detail, see Manual packaging.
binary

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X PATCH \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Content-Type: multipart/form-data" \ -d '{"tags":{},"file":"string"}' \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/modules/{moduleName}"

Response example

{ "dateModified": "2022-04-05T09:12:13Z"}

Get module spec


Get the OpenAPI specification for a given Cloud Code module
Authorizations
ServiceAccount (cloud_code.modules.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.modules.get

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

moduleName

string
필수
Name of a Cloud Code module.
minLength: 1maxLength: 50pattern: ^[a-zA-Z0-9_]+$

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/modules/{moduleName}/spec"

Response example

"openapi: 3.0.1\ninfo:\n title: ApiSpecExample OpenApi Specification\n version: 1.0.0\nservers:\n - url: https://cloud-code.services.api.unity.com/v1/projects/ApiSpecExample/modules/ApiSpecExample\npaths:\n /HelloWorld:\n post:\n description: HelloWorld POST\n requestBody:\n content:\n application/json:\n schema:\n type: object\n properties:\n params:\n type: object\n properties:\n name:\n type: string\n responses:\n '200':\n description: OK\n content:\n application/json:\n schema:\n properties:\n output:\n type: string\n /SendItem:\n post:\n description: SendItem POST\n requestBody:\n content:\n application/json:\n schema:\n type: object\n properties:\n params:\n type: object\n properties:\n item:\n $ref: '#/components/schemas/ApiSpecGenerationTest.Item'\n playerId:\n type: string\n responses:\n '200':\n description: OK\n content:\n application/json:\n schema:\n properties:\n output:\n type: object\n additionalProperties: false\n /GenerateLoot:\n post:\n description: GenerateLoot POST\n requestBody:\n content:\n application/json:\n schema:\n type: object\n properties:\n params:\n type: object\n properties:\n level:\n type: integer\n format: int32\n responses:\n '200':\n description: OK\n content:\n application/json:\n schema:\n properties:\n output:\n type: array\n items:\n $ref: '#/components/schemas/ApiSpecGenerationTest.Item'\ncomponents:\n schemas:\n ApiSpecGenerationTest.Item:\n properties:\n Name:\n type: string\n OwnerId:\n type: string\n Attributes:\n type: object\n additionalProperties:\n type: integer\n format: int32\n securitySchemes:\n BearerAuth:\n type: http\n scheme: bearer\nsecurity:\n - { }"

Get module state


Returns the live state of one scope - each class's state as JSON, plus any active timers.
Classes you can't update go under
clearOnly
instead of
modules
. That covers classes removed from the deployed module, classes with a custom IStateSerializer, and state not stored as JSON.
Returns 404 (problem code 9038) if the scope has no stored state, which includes the second or so after its first invocation. State outlives its player or session until its retention window ends, and each read refreshes that window.
To make an update conditional, pass the returned ETag as
If-Match
.
Authorizations
ServiceAccount (cloud_code.modules.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.modules.get

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

scopeType

string
필수
Scope type, matching the scope names used when running a module.
enum: "player", "multiplayerSession"

scopeId

string
필수
The scope instance - the player ID for
player
, or the multiplayer session ID for
multiplayerSession
.

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/state/{scopeType}/{scopeId}"

Response example

{ "clearOnly": { "TestProject": [ "CustomStateSerialization" ] }, "etag": "string", "modules": {}, "timers": { "timerMap": {} }}

Update module state


Overwrites the state of one scope. The API writes only the modules in the request and replaces each class you name whole. You can't write timers.
The API checks each entry against the deployed module first. The class must be one of the module's entrypoint classes, the JSON must deserialize into it, and it can't use a custom IStateSerializer. The API also refuses members the class doesn't declare, unless they're already in the stored state. If any check fails, you get a 400 and nothing changes.
If you send an ETag from an earlier read as
If-Match
and the state has changed since, you get a 412 and nothing changes. Returns 404 (problem code 9038) if the scope has no stored state, so you can't create state for a scope that has never run.
Authorizations
ServiceAccount (cloud_code.modules.update)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.modules.update

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

scopeType

string
필수
Scope type, matching the scope names used when running a module.
enum: "player", "multiplayerSession"

scopeId

string
필수
The scope instance - the player ID for
player
, or the multiplayer session ID for
multiplayerSession
.

Header parameters for "{title}"

If-Match

string
One or more ETags from earlier reads, comma separated. The API refuses the write with 412 unless one of them matches the live state.
*
matches any state, and weak tags never match.

Query parameters for "{title}"

version

integer
The module version to validate against. Defaults to the latest deployed version. When you set it, the request must name exactly one module. The API also checks pending timers registered on another version against that version.
format: int64

Request body for "{title}"

Media Type:
application/json

modules

object
필수
Keyed by module name, then C# type name. Each value is the class's complete state as plain JSON.

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X PUT \ -H "If-Match: <If-Match>" \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Content-Type: application/json" \ -d '{ "modules": {}}' \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/state/{scopeType}/{scopeId}"

Response example

{ "clearOnly": { "TestProject": [ "CustomStateSerialization" ] }, "etag": "string", "modules": {}, "timers": { "timerMap": {} }}

Clear module state


Clears the state of one scope. Set
target
to
modules
,
timers
or
all
(default).
Returns 404 (problem code 9038) if the scope has no stored state, which includes the second or so after its first invocation. Clearing a scope that's already clear returns 204.
Authorizations
ServiceAccount (cloud_code.modules.delete)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: cloud_code.modules.delete

Path parameters for "{title}"

projectId

string
필수
ID of the project.
example: 8bdacc33-6eef-4577-beb0-633c86259f5b

environmentId

string
필수
ID of the environment
example: 5v3fb205-d8a2-920f-8013-8c0e814777b3

scopeType

string
필수
Scope type, matching the scope names used when running a module.
enum: "player", "multiplayerSession"

scopeId

string
필수
The scope instance - the player ID for
player
, or the multiplayer session ID for
multiplayerSession
.

Query parameters for "{title}"

target

string
기본: all
The state category to clear.
enum: "modules", "timers", "all"

HTTP response status codes for "{title}":

Code samples for "{title}":

Request example

curl -X DELETE \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ "https://services.api.unity.com/cloud-code/v1/projects/{projectId}/environments/{environmentId}/state/{scopeType}/{scopeId}"

Response example

{ "type": "string", "title": "string", "status": 0, "requestId": "6203fac6-6579-4a71-a659-e20655580408", "code": 0, "detail": "string", "instance": "string", "details": [ {} ]}