Create a new mock API
curl --request POST \
--url https://wmc.wiremockapi.cloud/v1/mock-apis \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"mockApi": {
"name": "My new mock API",
"hostname": "my-new-mock-api",
"apiTemplateId": "8nd5x"
}
}
'import requests
url = "https://wmc.wiremockapi.cloud/v1/mock-apis"
payload = { "mockApi": {
"name": "My new mock API",
"hostname": "my-new-mock-api",
"apiTemplateId": "8nd5x"
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
mockApi: {name: 'My new mock API', hostname: 'my-new-mock-api', apiTemplateId: '8nd5x'}
})
};
fetch('https://wmc.wiremockapi.cloud/v1/mock-apis', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://wmc.wiremockapi.cloud/v1/mock-apis",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'mockApi' => [
'name' => 'My new mock API',
'hostname' => 'my-new-mock-api',
'apiTemplateId' => '8nd5x'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://wmc.wiremockapi.cloud/v1/mock-apis"
payload := strings.NewReader("{\n \"mockApi\": {\n \"name\": \"My new mock API\",\n \"hostname\": \"my-new-mock-api\",\n \"apiTemplateId\": \"8nd5x\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://wmc.wiremockapi.cloud/v1/mock-apis")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"mockApi\": {\n \"name\": \"My new mock API\",\n \"hostname\": \"my-new-mock-api\",\n \"apiTemplateId\": \"8nd5x\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://wmc.wiremockapi.cloud/v1/mock-apis")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"mockApi\": {\n \"name\": \"My new mock API\",\n \"hostname\": \"my-new-mock-api\",\n \"apiTemplateId\": \"8nd5x\"\n }\n}"
response = http.request(request)
puts response.read_body{
"mockApi": {
"id": "jjl8y",
"aclObject": "gkqjy",
"name": "My new mock API",
"description": "This is a sample mock API for testing purposes.",
"state": "RUNNING",
"adminSecurityEnabled": true,
"exportState": "EXPORT_ALLOWED",
"createdDate": "2024-08-23T21:34:36.595372Z",
"openApiGitIntegration": "jjl8y-openapi-integration-git",
"links": {
"self": "/v1/mock-apis/jjl8y",
"requests": "/v1/mock-apis/jjl8y/requests",
"mappings": "/v1/mock-apis/jjl8y/mappings",
"scenarios": "/v1/mock-apis/jjl8y/scenarios",
"recordings": {
"start": "/v1/mock-apis/jjl8y/recordings/start",
"stop": "/v1/mock-apis/jjl8y/recordings/stop",
"status": "/v1/mock-apis/jjl8y/recordings/status",
"snapshot": "/v1/mock-apis/jjl8y/recordings/snapshot"
},
"imports": "/v1/mock-apis/jjl8y/imports",
"organisation": "/v1/organisations/mgk7g",
"apiTemplate": "/v1/api-templates/8nd5x",
"aclObject": "/v1/acl/objects/gkqjy",
"aclRoles": "/v1/acl/objects/gkqjy/roles",
"invitations": "/v1/mock-apis/jjl8y/invitations",
"acl": "/v1/mock-apis/jjl8y/acl{?subjectId}",
"versionHistoryCommits": "/v1/mock-apis/jjl8y/version-history/commits"
},
"baseUrl": "https://jjl8y.wiremockapi.cloud",
"domainNames": [
{
"domainName": "my-new-mock-api.wiremockapi.cloud",
"editableSubdomainPart": "my-new-mock-api",
"urls": [
{
"url": "https://my-new-mock-api.wiremockapi.cloud"
},
{
"url": "http://my-new-mock-api.wiremockapi.cloud"
}
]
},
{
"domainName": "jjl8y.wiremockapi.cloud",
"urls": [
{
"url": "https://jjl8y.wiremockapi.cloud"
},
{
"url": "http://jjl8y.wiremockapi.cloud"
}
]
}
],
"domains": [
"jjl8y.wiremockapi.cloud",
"my-new-mock-api.wiremockapi.cloud"
]
}
}"Credentials are required to access this resource."{
"errors": [
{
"title": "Forbidden",
"source": {}
}
]
}{
"errors": [
{
"title": "Invalid JSON",
"detail": "json pointer /mockApi not present; it is required and must have json type object",
"source": {}
}
]
}{
"code": 123,
"message": "<string>"
}Mock APIs
Create a new mock API
POST
/
v1
/
mock-apis
Create a new mock API
curl --request POST \
--url https://wmc.wiremockapi.cloud/v1/mock-apis \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"mockApi": {
"name": "My new mock API",
"hostname": "my-new-mock-api",
"apiTemplateId": "8nd5x"
}
}
'import requests
url = "https://wmc.wiremockapi.cloud/v1/mock-apis"
payload = { "mockApi": {
"name": "My new mock API",
"hostname": "my-new-mock-api",
"apiTemplateId": "8nd5x"
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
mockApi: {name: 'My new mock API', hostname: 'my-new-mock-api', apiTemplateId: '8nd5x'}
})
};
fetch('https://wmc.wiremockapi.cloud/v1/mock-apis', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://wmc.wiremockapi.cloud/v1/mock-apis",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'mockApi' => [
'name' => 'My new mock API',
'hostname' => 'my-new-mock-api',
'apiTemplateId' => '8nd5x'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://wmc.wiremockapi.cloud/v1/mock-apis"
payload := strings.NewReader("{\n \"mockApi\": {\n \"name\": \"My new mock API\",\n \"hostname\": \"my-new-mock-api\",\n \"apiTemplateId\": \"8nd5x\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://wmc.wiremockapi.cloud/v1/mock-apis")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"mockApi\": {\n \"name\": \"My new mock API\",\n \"hostname\": \"my-new-mock-api\",\n \"apiTemplateId\": \"8nd5x\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://wmc.wiremockapi.cloud/v1/mock-apis")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"mockApi\": {\n \"name\": \"My new mock API\",\n \"hostname\": \"my-new-mock-api\",\n \"apiTemplateId\": \"8nd5x\"\n }\n}"
response = http.request(request)
puts response.read_body{
"mockApi": {
"id": "jjl8y",
"aclObject": "gkqjy",
"name": "My new mock API",
"description": "This is a sample mock API for testing purposes.",
"state": "RUNNING",
"adminSecurityEnabled": true,
"exportState": "EXPORT_ALLOWED",
"createdDate": "2024-08-23T21:34:36.595372Z",
"openApiGitIntegration": "jjl8y-openapi-integration-git",
"links": {
"self": "/v1/mock-apis/jjl8y",
"requests": "/v1/mock-apis/jjl8y/requests",
"mappings": "/v1/mock-apis/jjl8y/mappings",
"scenarios": "/v1/mock-apis/jjl8y/scenarios",
"recordings": {
"start": "/v1/mock-apis/jjl8y/recordings/start",
"stop": "/v1/mock-apis/jjl8y/recordings/stop",
"status": "/v1/mock-apis/jjl8y/recordings/status",
"snapshot": "/v1/mock-apis/jjl8y/recordings/snapshot"
},
"imports": "/v1/mock-apis/jjl8y/imports",
"organisation": "/v1/organisations/mgk7g",
"apiTemplate": "/v1/api-templates/8nd5x",
"aclObject": "/v1/acl/objects/gkqjy",
"aclRoles": "/v1/acl/objects/gkqjy/roles",
"invitations": "/v1/mock-apis/jjl8y/invitations",
"acl": "/v1/mock-apis/jjl8y/acl{?subjectId}",
"versionHistoryCommits": "/v1/mock-apis/jjl8y/version-history/commits"
},
"baseUrl": "https://jjl8y.wiremockapi.cloud",
"domainNames": [
{
"domainName": "my-new-mock-api.wiremockapi.cloud",
"editableSubdomainPart": "my-new-mock-api",
"urls": [
{
"url": "https://my-new-mock-api.wiremockapi.cloud"
},
{
"url": "http://my-new-mock-api.wiremockapi.cloud"
}
]
},
{
"domainName": "jjl8y.wiremockapi.cloud",
"urls": [
{
"url": "https://jjl8y.wiremockapi.cloud"
},
{
"url": "http://jjl8y.wiremockapi.cloud"
}
]
}
],
"domains": [
"jjl8y.wiremockapi.cloud",
"my-new-mock-api.wiremockapi.cloud"
]
}
}"Credentials are required to access this resource."{
"errors": [
{
"title": "Forbidden",
"source": {}
}
]
}{
"errors": [
{
"title": "Invalid JSON",
"detail": "json pointer /mockApi not present; it is required and must have json type object",
"source": {}
}
]
}{
"code": 123,
"message": "<string>"
}⌘I