Install Inttegro’s published Simfile, create a local application profile, and run your integration against the emulator. This walkthrough covers public and authenticated requests, exact failure scenarios, retries, and isolated test state.
Prerequisites
- A supported Simile installation from the Simile downloads
- cURL or one of the server runtimes shown below
- An integration that can read its base URL and API key from environment variables
Install the Inttegro Simfile
Install Simile with Homebrew:
brew install inttegro/tap/simileOn macOS or Linux, you can use the project installer instead:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/inttegro/simile/HEAD/install.sh)"Download the published Inttegro contract bundle.
It contains the Inttegro Simfile,
its public HCL modules, and the API contract that the Simfile references.
Extract the published contract and simile/ directory together:
mkdir -p inttegro-test-mode
cd inttegro-test-mode
curl -fsSL https://github.com/inttegro/openapi/archive/refs/heads/master.tar.gz \
| tar -xzf - --strip-components=1 \
openapi-master/commerce.yml \
openapi-master/simile
cd simile
simile registerRegistration compiles the OpenAPI contract and public HCL modules before
installing an immutable local revision. simile register discovers ./Simfile
and reads its inttegro service name. For repeatable CI, download
https://github.com/inttegro/openapi/archive/<commit>.tar.gz and replace the
openapi-master/ archive member prefix with openapi-<commit>/.
Create an application profile for your integration. The credential is synthetic, stored locally, and valid only in this emulator:
simile setup inttegro \
--profile checkout \
--set name="Checkout development" \
--use \
--reporting off
simile profiles inttegro
simile profile inttegro checkoutSetup writes the generated API_KEY, APPLICATION_ID, and profile metadata to
the private environment file reported by simile profile. Keep that file out
of source control. --reporting off makes the local reporting choice explicit.
Run the local API
Start the registered service in one terminal:
simile start inttegroThe published listener is http://127.0.0.1:4242. In another terminal, load
the setup-created environment. The file also sets SIMILE_BASE_URL:
set -a
. "${SIMILE_HOME:-$HOME/.simile}/profiles/inttegro/checkout.env"
set +aThe following example first calls the public country-specification operation, then creates an authenticated, finalized order. The same payload and idempotency key can be repeated safely.
Call the local Inttegro API
: "${SIMILE_BASE_URL:?Run Simile and load the profile environment}"
: "${API_KEY:?Load the Simile profile environment}"
curl --fail-with-body "$SIMILE_BASE_URL/spec/countries" \
-H 'Content-Type: application/json' \
-d '{}'
curl --fail-with-body "$SIMILE_BASE_URL/orders/create" \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: simile-order-001' \
-d '{
"request_meta": { "idempotency_key": "simile-order-001" },
"number": "SIMILE-ORDER-001",
"finalize": true,
"execute_payment": false,
"customer_data": {
"name": "Ama Mensah",
"email_address": "ama@example.test"
},
"line_items": [{
"type": "product",
"product": {
"type": "physical",
"name": "Premium Cotton T-Shirt",
"quantity": 1,
"price": { "currency": "ghs", "value": 20000 }
}
}]
}'const baseUrl = process.env.SIMILE_BASE_URL
const apiKey = process.env.API_KEY
if (!baseUrl || !apiKey) throw new Error('Load the Simile profile environment')
const countries = await fetch(`${baseUrl}/spec/countries`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: '{}',
})
if (!countries.ok) throw new Error(await countries.text())
const order = await fetch(`${baseUrl}/orders/create`, {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
'Idempotency-Key': 'simile-order-001',
},
body: JSON.stringify({
request_meta: { idempotency_key: 'simile-order-001' },
number: 'SIMILE-ORDER-001',
finalize: true,
execute_payment: false,
customer_data: { name: 'Ama Mensah', email_address: 'ama@example.test' },
line_items: [
{
type: 'product',
product: {
type: 'physical',
name: 'Premium Cotton T-Shirt',
quantity: 1,
price: { currency: 'ghs', value: 20000 },
},
},
],
}),
})
if (!order.ok) throw new Error(await order.text())
console.log(await order.json())package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func call(method, url, token, body string) []byte {
request, err := http.NewRequest(method, url, bytes.NewBufferString(body))
if err != nil { panic(err) }
request.Header.Set("Content-Type", "application/json")
if token != "" { request.Header.Set("Authorization", "Bearer "+token) }
if token != "" { request.Header.Set("Idempotency-Key", "simile-order-001") }
response, err := http.DefaultClient.Do(request)
if err != nil { panic(err) }
defer response.Body.Close()
result, err := io.ReadAll(response.Body)
if err != nil { panic(err) }
if response.StatusCode >= 300 { panic(string(result)) }
return result
}
func main() {
baseURL, apiKey := os.Getenv("SIMILE_BASE_URL"), os.Getenv("API_KEY")
if baseURL == "" || apiKey == "" { panic("load the Simile profile environment") }
call(http.MethodPost, baseURL+"/spec/countries", "", `{}`)
body := `{"request_meta":{"idempotency_key":"simile-order-001"},` +
`"number":"SIMILE-ORDER-001","finalize":true,"execute_payment":false,` +
`"customer_data":{"name":"Ama Mensah","email_address":"ama@example.test"},` +
`"line_items":[{"type":"product","product":{"type":"physical",` +
`"name":"Premium Cotton T-Shirt","quantity":1,` +
`"price":{"currency":"ghs","value":20000}}}]}`
fmt.Println(string(call(http.MethodPost, baseURL+"/orders/create", apiKey, body)))
}import json
import os
import urllib.request
base_url = os.environ['SIMILE_BASE_URL']
api_key = os.environ['API_KEY']
public_request = urllib.request.Request(
f'{base_url}/spec/countries',
data=b'{}',
headers={'Content-Type': 'application/json'},
method='POST',
)
with urllib.request.urlopen(public_request) as response:
response.read()
payload = {
'request_meta': {'idempotency_key': 'simile-order-001'},
'number': 'SIMILE-ORDER-001',
'finalize': True,
'execute_payment': False,
'customer_data': {'name': 'Ama Mensah', 'email_address': 'ama@example.test'},
'line_items': [{
'type': 'product',
'product': {
'type': 'physical',
'name': 'Premium Cotton T-Shirt',
'quantity': 1,
'price': {'currency': 'ghs', 'value': 20000},
},
}],
}
order_request = urllib.request.Request(
f'{base_url}/orders/create',
data=json.dumps(payload).encode(),
headers={
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json',
'Idempotency-Key': 'simile-order-001',
},
method='POST',
)
with urllib.request.urlopen(order_request) as response:
print(json.load(response))<?php
$baseUrl = getenv('SIMILE_BASE_URL');
$apiKey = getenv('API_KEY');
if (!$baseUrl || !$apiKey) {
throw new RuntimeException('Load the Simile profile environment');
}
function post(string $url, array $headers, string $body): string {
$request = curl_init($url);
curl_setopt_array($request, [
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
if ($response === false || $status >= 300) {
throw new RuntimeException($response ?: curl_error($request));
}
return $response;
}
post($baseUrl . '/spec/countries', ['Content-Type: application/json'], '{}');
$payload = [
'request_meta' => ['idempotency_key' => 'simile-order-001'],
'number' => 'SIMILE-ORDER-001',
'finalize' => true,
'execute_payment' => false,
'customer_data' => ['name' => 'Ama Mensah', 'email_address' => 'ama@example.test'],
'line_items' => [[
'type' => 'product',
'product' => [
'type' => 'physical',
'name' => 'Premium Cotton T-Shirt',
'quantity' => 1,
'price' => ['currency' => 'ghs', 'value' => 20000],
],
]],
];
echo post($baseUrl . '/orders/create', [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
'Idempotency-Key: simile-order-001',
], json_encode($payload, JSON_THROW_ON_ERROR));require 'json'
require 'net/http'
base_url = ENV.fetch('SIMILE_BASE_URL')
api_key = ENV.fetch('API_KEY')
def post(url, body, headers = {})
uri = URI(url)
request = Net::HTTP::Post.new(uri, { 'Content-Type' => 'application/json' }.merge(headers))
request.body = JSON.generate(body)
response = Net::HTTP.start(uri.host, uri.port) { |http| http.request(request) }
raise "Inttegro API #{response.code}: #{response.body}" unless response.is_a?(Net::HTTPSuccess)
JSON.parse(response.body)
end
post("#{base_url}/spec/countries", {})
order = post("#{base_url}/orders/create", {
request_meta: { idempotency_key: 'simile-order-001' },
number: 'SIMILE-ORDER-001',
finalize: true,
execute_payment: false,
customer_data: { name: 'Ama Mensah', email_address: 'ama@example.test' },
line_items: [{
type: 'product',
product: {
type: 'physical', name: 'Premium Cotton T-Shirt', quantity: 1,
price: { currency: 'ghs', value: 20_000 },
},
}],
}, {
'Authorization' => "Bearer #{api_key}",
'Idempotency-Key' => 'simile-order-001',
})
puts JSON.pretty_generate(order)import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class SimileExample {
static final HttpClient client = HttpClient.newHttpClient();
static String post(String url, String token, String body) throws Exception {
var builder = HttpRequest.newBuilder(URI.create(url))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body));
if (token != null) {
builder.header("Authorization", "Bearer " + token)
.header("Idempotency-Key", "simile-order-001");
}
var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new RuntimeException(response.body());
return response.body();
}
public static void main(String[] args) throws Exception {
String baseUrl = System.getenv("SIMILE_BASE_URL");
String apiKey = System.getenv("API_KEY");
if (baseUrl == null || apiKey == null) throw new IllegalStateException("Load the Simile profile environment");
post(baseUrl + "/spec/countries", null, "{}");
String body = """
{"request_meta":{"idempotency_key":"simile-order-001"},
"number":"SIMILE-ORDER-001","finalize":true,"execute_payment":false,
"customer_data":{"name":"Ama Mensah","email_address":"ama@example.test"},
"line_items":[{"type":"product","product":{"type":"physical",
"name":"Premium Cotton T-Shirt","quantity":1,
"price":{"currency":"ghs","value":20000}}}]}
""";
System.out.println(post(baseUrl + "/orders/create", apiKey, body));
}
}using System.Net.Http.Headers;
using System.Text;
var baseUrl = Environment.GetEnvironmentVariable("SIMILE_BASE_URL")
?? throw new InvalidOperationException("Load the Simile profile environment");
var apiKey = Environment.GetEnvironmentVariable("API_KEY")
?? throw new InvalidOperationException("Load the Simile profile environment");
using var client = new HttpClient();
var publicResponse = await client.PostAsync(
$"{baseUrl}/spec/countries",
new StringContent("{}", Encoding.UTF8, "application/json"));
publicResponse.EnsureSuccessStatusCode();
var body = """
{"request_meta":{"idempotency_key":"simile-order-001"},
"number":"SIMILE-ORDER-001","finalize":true,"execute_payment":false,
"customer_data":{"name":"Ama Mensah","email_address":"ama@example.test"},
"line_items":[{"type":"product","product":{"type":"physical",
"name":"Premium Cotton T-Shirt","quantity":1,
"price":{"currency":"ghs","value":20000}}}]}
""";
using var orderRequest = new HttpRequestMessage(HttpMethod.Post, $"{baseUrl}/orders/create");
orderRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
orderRequest.Headers.Add("Idempotency-Key", "simile-order-001");
orderRequest.Content = new StringContent(body, Encoding.UTF8, "application/json");
var orderResponse = await client.SendAsync(orderRequest);
orderResponse.EnsureSuccessStatusCode();
Console.WriteLine(await orderResponse.Content.ReadAsStringAsync());The order response has a generated or_ identifier, the supplied order
number, a requires_payment status, and a GHS 200.00 total. Look it up through
Look up an order to verify that later requests
observe the stored public snapshot.
Exercise outcomes, retries, and state
Run application tests under Simile when you want the base URL and selected profile injected automatically:
simile test inttegro --profile checkout -- ./scripts/integration-testThe child receives SIMILE_BASE_URL, API_KEY, APPLICATION_ID, and the
selected profile metadata. Simile owns the emulator for the test process,
returns the child’s exit status, and shuts the listener down afterward.
Use a named scenario for one documented result. This example makes refund
cancellation return the reviewed 409 refund_cannot_cancel response:
simile test inttegro \
--profile checkout \
--scenario refund_cannot_cancel \
-- ./scripts/integration-test refund-cannot-cancelFor lost-response recovery, use order_response_lost_after_commit. It commits
order creation, closes delivery before the response arrives, and lets the test
retry the same request with the same idempotency key. Reusing that key with a
changed body returns Inttegro’s documented idempotency error instead of creating
a second order.
Inspect the available scenarios and persisted causal history without printing stored values:
simile describe service inttegro --verbose
simile state inttegroPass --values to simile state only in a controlled local or CI environment;
stored snapshots can contain customer data supplied by your tests.
Report an inconsistency
Please report a contradiction when the emulator and Inttegro’s documented or observed public behavior disagree. Do not hide the mismatch behind test-only branches or weaken an assertion to make the test pass. A small reproducible report helps Inttegro correct the published contract or test behavior for every integration.
The earlier --reporting off option disables automatic submission only. You
can still prepare, inspect, and explicitly send a one-off report. Simile’s
issue-reporting workflow
captures the operation, compiled contract, request, seed, and selected controls
in a reproduction bundle; verifies the failure; and stores the report locally
for review before anything is sent.
If you want Simile to report reproducible internal emulator failures while the service or supervised tests run, opt in for this profile and provide an address where Inttegro can ask follow-up questions:
simile reporting inttegro --profile checkout
simile reporting inttegro \
--profile checkout \
--mode automatic \
--contact developer@example.comAutomatic reporting remains profile-scoped and can be withdrawn at any time:
simile reporting inttegro --profile checkout --mode offFor a mismatch you observe yourself, follow the manual workflow to capture the
smallest failing request, prepare a report with what you expected and what
happened, inspect the saved report.json and reproduction bundle, and then use
simile report REPORT_ID --send --contact you@example.com. Replace the example
address with one you control. Use synthetic profile credentials and test data;
never attach production keys, secrets, or customer records.
Isolate or reset state
Set SIMILE_HOME before registration to choose the state boundary. A stable
directory preserves profiles and declared resource state across runs:
export SIMILE_HOME="$PWD/.simile-inttegro"Give each CI job or parallel worker a fresh directory. To reset one named local service, stop it, remove that registration and its service state, then register and set it up again:
simile remove inttegro --confirm inttegro
simile register
simile setup inttegro --profile checkout --set name="Checkout development" --use --reporting offRun reset commands from the downloaded simile/ directory so simile register
can find ./Simfile. Review the testing boundary
before deciding which checks still require deployed-application or
production-readiness verification.
Related resources
- Simile documentation - CLI lifecycle, profiles, scenarios, and current limits
- Report an issue with Simile - Capture, review, and submit a reproducible inconsistency
- Published Inttegro Simfile - Downloadable local test-mode entrypoint
- Idempotent requests - Stable retry keys and conflict behavior
- Orders API - Complete create-order contract