(mt):Add service using API
- This page was last modified on February 18, 2011, at 09:54.
From (mt) Community Wiki
This method provides a way to add a new (mt) Media Temple service to the authenticated account.
Contents |
Request Info
The following URL and HTTP method should be used:
| HTTP Method | URL |
|---|---|
| POST |
|
The following data must be provided as a type-specific object (JSON/XML) in the body of the request:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| serviceType | int | yes | n/a | The service type. See also Service type. |
| operatingSystem | int | no | 16 (Ubuntu 9.10 Karmic) | The operating system the service will be provision with. Only available for (ve) services. See also Operating system. |
| primaryDomain | String | yes (dv only) | (ve) auto-generates a domain | The primary domain name for the new service. |
Example JSON object
{
"serviceType": 668,
"primaryDomain": "blah.com"
"operatingSystem": 16
}
Response Info
The response will return an HTTP status code to indicate the general category of success or failure to the client. More specific error codes and messages will be contained in the response data itself, if provided. For more information on response codes and parsing response data, see Parsing API responses.
Sample Request
To add a new service of service type 668, do the following:
curl -D log.txt -s -X "POST" -d '{ "serviceType": 668, "primaryDomain": "blah.com", "operatingSystem": 16}' \
-H "Content-type: application/json" \
"https://api.mediatemple.net/api/v1/services.json?apikey=a5h34sf62..."
Sample Response
Here is an example of the returned result:
{
"response" : {
"statusCode" : 202,
"timeStamp" : 1284609174311,
"date" : "2010-09-16T03:52:54.311+0000",
"errors" : [ ],
"custom" : [ ]
}
}
Response Errors
All responses should be in the standard response format. For more information, see Parsing API responses.
| Status Code | Error Code | Error Description |
|---|---|---|
| 400 | InvalidServiceType | The requested service type is not valid. |
| 400 | InvalidDomain | A domain must be specified for this service. |
| 400 | InvalidOS | The requested Operating System is not valid. |
| 402 | PaymentFailed | This order was not able to complete due to payment problems. |
| 500 | UnknownError | There was an unexpected error. |