Click to view Sandbox Init Bundle file
```json
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"resource": {
"resourceType": "FHIRSchema",
"url": "http://aidbox.app/StructureDefinition/Client/created-by",
"id": "client-created-by",
"base": "Extension",
"name": "client-created-by",
"kind": "complex-type",
"type": "Extension",
"version": "0.0.1",
"elements": {
"url": {
"fixed": "http://aidbox.app/StructureDefinition/Client/created-by"
},
"value": {
"choices": ["valueReference"]
},
"valueReference": {
"type": "Reference",
"refers": ["User"],
"choiceOf": "value"
}
},
"derivation": "constraint"
},
"request": {
"method": "PUT",
"url": "FHIRSchema/client-created-by"
}
},
{
"resource": {
"resourceType": "SearchParameter",
"id": "Client.created-by",
"url": "http://aidbox.app/StructureDefinition/Client/created-by",
"name": "created-by",
"status": "active",
"code": "created-by",
"base": ["Client"],
"type": "token",
"description": "Client created-by User",
"expression": "Client.meta.extension.where(url='http://aidbox.app/StructureDefinition/Client/created-by').value.Reference.id"
},
"request": {
"method": "PUT",
"url": "SearchParameter/Client.created-by"
}
},
{
"resource": {
"resourceType": "FHIRSchema",
"url": "http://aidbox.app/StructureDefinition/Client/status",
"id": "client-status",
"base": "Extension",
"name": "client-status",
"kind": "complex-type",
"type": "Extension",
"version": "0.0.2",
"elements": {
"url": {
"fixed": "http://aidbox.app/StructureDefinition/Client/status"
},
"value": {
"choices": ["valueCode"]
},
"valueCode": {
"type": "code",
"choiceOf": "value",
"constraints": {
"enum-client-status": {
"severity": "error",
"expression": "%context.subsetOf('draft' | 'review' | 'active' | 'rejected')"
}
}
}
},
"derivation": "constraint"
},
"request": {
"method": "PUT",
"url": "FHIRSchema/client-status"
}
},
{
"resource": {
"resourceType": "SearchParameter",
"id": "Client.status",
"url": "http://aidbox.app/StructureDefinition/Client/status",
"name": "status",
"status": "active",
"code": "status",
"base": ["Client"],
"type": "token",
"description": "Client status (draft, review, active, rejected)",
"expression": "Client.meta.extension.where(url='http://aidbox.app/StructureDefinition/Client/status').value.code"
},
"request": {
"method": "PUT",
"url": "SearchParameter/Client.status"
}
},
{
"resource": {
"source": "https://storage.googleapis.com/aidbox-public/smartbox/all_data.ndjson.gz"
},
"request": {
"method": "POST",
"url": "/$load"
}
},
{
"resource": {
"resourceType": "Client",
"id": "smartbox-developer-portal",
"first_party": true,
"grant_types": ["code"],
"scope": ["openid", "profile", "email"],
"auth": {
"authorization_code": {
"redirect_uri": "http://localhost:8096/api/developer/auth/callback",
"access_token_expiration": 3600,
"token_format": "jwt",
"pkce": true,
"refresh_token": true,
"refresh_token_expiration": 86400
}
}
},
"request": {
"method": "PUT",
"url": "Client/smartbox-developer-portal"
}
},
{
"resource": {
"fhirUser": {
"reference": "Patient/test-pt-1"
}
},
"request": {
"method": "PATCH",
"url": "User/admin"
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/dev-can-get-launch-uri"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "dev-can-get-launch-uri",
"type": "rpc",
"engine": "matcho-rpc",
"rpc": {
"aidbox.smart/get-launch-uri": {
"user": {
"fhirUser": {
"resourceType": "Patient"
}
}
}
}
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/dev-smart-app-read"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "dev-smart-app-read",
"type": "rest",
"engine": "matcho",
"matcho": {
"client": {
"type": "smart-app"
},
"operation": {
"id": {
"$one-of": ["FhirSearch", "FhirRead"]
}
}
}
}
},
{
"resource": {
"resourceType": "Client",
"id": "developer-api",
"secret": "developer-api-secret-change-in-production",
"grant_types": ["client_credentials"]
},
"request": {
"method": "PUT",
"url": "Client/developer-api"
}
},
{
"resource": {
"resourceType": "AccessPolicy",
"id": "developer-api",
"engine": "matcho",
"description": "Scoped access for developer API client (sessions, oauth state, orgs, users)",
"matcho": {
"client": {
"id": "developer-api"
},
"$one-of": [
{
"params": {
"resource/type": "Session"
},
"operation": {
"id": {
"$one-of": [
"FhirCreate",
"FhirSearch",
"FhirRead",
"FhirUpdate",
"FhirPatch"
]
}
}
},
{
"params": {
"resource/type": "Organization"
},
"operation": {
"id": {
"$one-of": ["FhirSearch", "FhirRead"]
}
}
},
{
"params": {
"resource/type": "User"
},
"operation": {
"id": "FhirRead"
}
}
]
}
},
"request": {
"method": "PUT",
"url": "AccessPolicy/developer-api"
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/dev-client-search-own"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "dev-client-search-own",
"engine": "matcho",
"description": "Developers can search only their own Client apps",
"matcho": {
"user": {
"roles": {
"$contains": {
"type": "developer"
}
}
},
"operation": {
"id": "FhirSearch"
},
"params": {
"resource/type": "Client",
"created-by": ".user.id"
}
}
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/dev-client-read-write-own"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "dev-client-read-write-own",
"engine": "sql",
"sql": {
"query": "select true from client where id = {{params.resource/id}}\n and exists (\n select 1\n from jsonb_array_elements(resource->'meta'->'extension') ext\nwhere ext->>'url' = 'http://aidbox.app/StructureDefinition/Client/created-by'\n and ext #>> '{value,Reference,id}' = {{user.id}});"
}
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/dev-client-create-self-owned"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "dev-client-create-self-owned",
"engine": "matcho",
"description": "Developers can create Client apps only when created-by points to themselves",
"matcho": {
"user": {
"roles": {
"$contains": {
"type": "developer"
}
}
},
"operation": {
"id": "FhirCreate"
},
"params": {
"resource/type": "Client"
},
"resource": {
"meta": {
"extension": {
"$contains": {
"url": "http://aidbox.app/StructureDefinition/Client/created-by",
"value": {
"Reference": {
"id": ".user.id"
}
}
}
}
}
}
}
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/developer-user-read-self"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "developer-user-read-self",
"engine": "matcho",
"description": "Developers can read only their own User resource",
"matcho": {
"user": {
"roles": {
"$contains": {
"type": "developer"
}
}
},
"operation": {
"id": "FhirRead"
},
"params": {
"resource/type": "User",
"resource/id": ".user.id"
}
}
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/admin-review-sandbox-clients"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "admin-review-sandbox-clients",
"engine": "matcho",
"description": "Admins can review sandbox Clients (read/search only)",
"matcho": {
"user": {
"roles": {
"$contains": {
"type": "admin"
}
}
},
"params": {
"resource/type": "Client"
},
"operation": {
"id": {
"$one-of": ["FhirSearch", "FhirRead"]
}
}
}
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/admin-role-access"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "admin-role-access",
"description": "Role-based access policy for administrators - allows full system access",
"engine": "matcho",
"matcho": {
"user": {
"roles": {
"contains": {
"type": "admin"
}
}
}
}
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/patient-role-access"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "patient-role-access",
"description": "Role-based access policy for patients - allows access to own data and consent management",
"engine": "matcho",
"matcho": {
"user": {
"roles": {
"contains": {
"type": "patient"
}
}
},
"operation": {
"id": {
"$one-of": [
"FhirSearch",
"FhirRead",
"FhirPatch",
"FhirCreate",
"FhirUpdate"
]
}
},
"$or": [
{
"params": {
"resource/type": "Patient"
},
"operation": {
"id": {
"$one-of": ["FhirRead"]
}
}
},
{
"params": {
"resource/type": "Consent"
},
"operation": {
"id": {
"$one-of": [
"FhirSearch",
"FhirRead",
"FhirPatch",
"FhirCreate",
"FhirUpdate"
]
}
}
}
]
}
}
},
{
"request": {
"method": "PUT",
"url": "NotificationTemplate/auth-signup-email"
},
"resource": {
"resourceType": "NotificationTemplate",
"template": "\nConfirm your email address
\nHello {{params.data.name}}{{params.email}}{{params.username}}!
\nWe just need to verify that {{params.email}} {{params.username}} is your email address.
\nConfirm Email Address
\nDidn't request this email?\nNo worries! Your address may have been entered by mistake. If you ignore or delete this email, nothing further will happen.
\nIf you're having problems, please feel free to write to us at hello@health-samurai.io. We'll be glad to help.
"
}
},
{
"request": {
"method": "PUT",
"url": "TokenIntrospector/admin-aidbox"
},
"resource": {
"resourceType": "TokenIntrospector",
"id": "admin-aidbox",
"type": "jwt",
"jwt": {
"iss": "http://localhost:8080"
},
"jwks_uri": "http://aidbox-admin:8080/.well-known/jwks.json"
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/allow-admin-tokens"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "allow-admin-tokens",
"description": "Allow requests authenticated with Admin Aidbox JWT tokens",
"engine": "json-schema",
"schema": {
"required": ["jwt"],
"properties": {
"jwt": {
"required": ["iss"],
"properties": {
"iss": {
"constant": "http://localhost:8080"
}
}
}
}
}
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/dev-client-search-communication"
},
"resource": {
"engine": "matcho",
"matcho": {
"user": {
"roles": {
"$contains": {
"type": "developer"
}
}
},
"params": {
"resource/type": "Communication",
".about.0.reference": "present?"
},
"operation": {
"id": "FhirSearch"
}
},
"description": "Developers can search communication for sertain app",
"id": "dev-client-search-communication",
"resourceType": "AccessPolicy"
}
},
{
"request": {
"method": "PUT",
"url": "AccessPolicy/smart-app-can-read-patient-api"
},
"resource": {
"resourceType": "AccessPolicy",
"id": "smart-app-can-read-patient-api",
"engine": "matcho",
"matcho": {
"jwt": {
"atv": 2,
"scope": "present?",
"context": {
"patient": "present?"
}
},
"client": {
"type": "smart-app",
"active": true
}
}
}
}
]
}
```
#### **Step 5: Create Init Bundle for Admin Aidbox**