{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://agrirouter.com/api/credentials-package.schema.json","title":"agrirouter Application Credentials Package","description":"A self-contained JSON package for one agrirouter G4 API application software version and one OAuth client.","type":"object","additionalProperties":false,"required":["$schema","schema_version","package_type","issued_at","application","software_version","oauth_client","authorization_server","api"],"properties":{"$schema":{"type":"string","const":"https://agrirouter.com/api/credentials-package.schema.json","description":"Absolute URL of the JSON Schema that describes this credentials package contract."},"schema_version":{"type":"string","const":"1.0.0","description":"Version of the agrirouter credentials package contract used by this file."},"package_type":{"type":"string","const":"agrirouter_application_credentials","description":"Stable package discriminator for agrirouter application credentials."},"issued_at":{"type":"string","format":"date-time","description":"UTC timestamp when the portal generated this credentials package."},"application":{"type":"object","description":"The saved agrirouter Developer Portal application this package belongs to.","additionalProperties":false,"required":["id","name","type","tenant_id"],"properties":{"id":{"type":"string","minLength":1,"description":"Application ID from the Developer Portal. Use it when an integration needs to identify the registered application."},"name":{"type":"string","minLength":1,"description":"Human-readable application name from the portal."},"type":{"type":"string","const":"G4_APPLICATION","description":"Application type. Credentials packages are currently issued for G4 API applications."},"tenant_id":{"type":"string","minLength":1,"description":"Developer tenant that owns the registered application."},"deep_url":{"type":"string","format":"uri","description":"Optional deep URL configured for the application and shown during discovery or user handoff flows."},"support_url":{"type":"string","format":"uri","description":"Optional support URL configured for the application and shown to users or reviewers."}}},"software_version":{"type":"object","description":"Exactly one approved or testing-approved software version selected for this package.","additionalProperties":false,"required":["version_id","version_number","status","description"],"properties":{"version_id":{"type":"string","minLength":1,"description":"Software version ID from the Developer Portal. This identifies the exact application version the credentials package was prepared for."},"version_number":{"type":"integer","minimum":0,"description":"Developer-managed software version number. The portal defaults this to the latest package-eligible version."},"status":{"type":"string","enum":["APPROVED_FOR_TESTING","APPROVED"],"description":"Lifecycle status of the selected software version at package generation time."},"description":{"type":"string","description":"Developer-provided software version description shown in the portal."}}},"oauth_client":{"type":"object","description":"Exactly one OAuth client selected for this package. Existing stored secrets are never retrieved by the portal.","additionalProperties":false,"required":["name","client_id","client_secret","redirect_uris","grant_types","token_endpoint_auth_method","client_id_issued_at","client_secret_expires_at"],"properties":{"name":{"type":"string","minLength":1,"description":"Human-readable OAuth client name from the Developer Portal."},"client_id":{"type":"string","minLength":1,"description":"OAuth client identifier to send to the agrirouter token endpoint."},"client_secret":{"type":"string","minLength":1,"description":"OAuth client secret. This is a real one-time secret only when downloaded immediately after client creation or rotation; later downloads contain a placeholder."},"redirect_uris":{"type":"array","description":"Registered redirect URI for the OAuth client. The credentials package contains exactly one redirect URI.","minItems":1,"maxItems":1,"items":{"type":"string","format":"uri"}},"grant_types":{"type":"array","description":"OAuth grant types expected for this client credentials package.","minItems":1,"items":{"type":"string","enum":["client_credentials"]}},"token_endpoint_auth_method":{"type":"string","enum":["client_secret_post","client_secret_basic"],"description":"Preferred OAuth client authentication method for the token endpoint."},"client_id_issued_at":{"type":"integer","minimum":0,"description":"OAuth client creation time as seconds since the Unix epoch."},"client_secret_expires_at":{"type":"integer","minimum":0,"description":"OAuth client secret expiration as seconds since the Unix epoch. A value of 0 means no explicit expiry is published."}}},"authorization_server":{"type":"object","description":"OAuth authorization server metadata needed to send users through consent and request tokens.","additionalProperties":false,"required":["authorization_endpoint","token_endpoint","scopes_supported","token_endpoint_auth_methods_supported"],"properties":{"authorization_endpoint":{"type":"string","format":"uri","description":"Authorization endpoint for agrirouter user consent in the package's runtime environment."},"token_endpoint":{"type":"string","format":"uri","description":"Token endpoint for exchanging OAuth client credentials in the package's runtime environment."},"scopes_supported":{"type":"array","description":"OAuth scopes documented for agrirouter G4 API integrations.","items":{"type":"string","enum":["endpoints:manage"]}},"token_endpoint_auth_methods_supported":{"type":"array","description":"OAuth client authentication methods supported by the agrirouter token endpoint.","minItems":1,"items":{"type":"string","enum":["client_secret_post","client_secret_basic"]}}}},"api":{"type":"object","description":"G4 API endpoint for the package's runtime environment and public OpenAPI contract URLs.","additionalProperties":false,"required":["base_url","openapi_json_url","openapi_yaml_url"],"properties":{"base_url":{"type":"string","format":"uri","description":"Base URL for agrirouter G4 API calls."},"openapi_json_url":{"type":"string","format":"uri","description":"Public OpenAPI specification URL in JSON format."},"openapi_yaml_url":{"type":"string","format":"uri","description":"Public OpenAPI specification URL in YAML format."}}}}}