{"result":{"depiction_url":null,"edges":{"in_module":{"objects":[{"created":"2026-09-09T13:48:11Z","object_id":{"id":335,"is_a":["text","documentation","reference","module"],"name":"doc_core","title":"Zotonic Core","uri":"https:\/\/zotonic.com\/id\/335"},"seq":1}],"predicate":{"id":333,"is_a":["meta","predicate"],"name":"in_module","title":{"_type":"trans","tr":{"en":"In module"}},"uri":"https:\/\/zotonic.com\/id\/in_module"}},"subject":{"objects":[{"created":"2026-09-09T13:48:11Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2564,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_backend_developer","title":"Backend developer","uri":"https:\/\/zotonic.com\/id\/2564"},"seq":2},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2608,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_routing_and_redirects","title":"Routing and redirects","uri":"https:\/\/zotonic.com\/id\/2608"},"seq":3},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2625,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_model","title":"Model","uri":"https:\/\/zotonic.com\/id\/2625"},"seq":4},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2628,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_dispatch_rule","title":"Dispatch rule","uri":"https:\/\/zotonic.com\/id\/2628"},"seq":5},{"created":"2026-09-09T13:48:11Z","object_id":{"id":2667,"is_a":["categorization","keyword","keyword_data_type"],"name":"zotonic_topic_url","title":"URL","uri":"https:\/\/zotonic.com\/id\/2667"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":2437,"is_a":["text","documentation","reference","model"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2437"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_model_model_dispatch","page_url":{"en":"https:\/\/zotonic.com\/docs\/2437\/dispatch","x-default":"https:\/\/zotonic.com\/docs\/2437\/dispatch"},"preview_url":null,"resource":{"version":104,"pivot_location_lat":null,"title":"dispatch","is_authoritative":true,"body":"<p>Dispatch or generate URLs or page paths. Useful to check dispatch rules or for client side code to dispatch page paths.<\/p>\n<h2>Dispatching URLs<\/h2>\n<p>The <code>path<\/code> returns the matched dispatch rule, controller, controller options, language, bindings and other dispatch information.<\/p>\n<p>If no dispatch rule matches then 404 Not Found is returned.<\/p>\n<p>Example:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-bash\">curl -k &#39;https:\/\/example.test:8443\/api\/model\/dispatch\/get\/path\/nl\/page\/1234\/hello&#39;\n<\/code><\/pre>\n<p>Returns:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-json\">{\n    &quot;result&quot;: {\n        &quot;bindings&quot;: {\n            &quot;id&quot;: &quot;1234&quot;,\n            &quot;z_language&quot;: &quot;nl&quot;,\n            &quot;zotonic_site&quot;: &quot;example&quot;,\n            &quot;zotonic_dispatch_path&quot;: [\n                &quot;page&quot;,\n                &quot;1234&quot;,\n                &quot;hello&quot;\n            ],\n            &quot;zotonic_dispatch&quot;: &quot;page&quot;,\n            &quot;slug&quot;: &quot;hello&quot;\n        },\n        &quot;controller&quot;: &quot;controller_page&quot;,\n        &quot;site&quot;: &quot;example&quot;,\n        &quot;language&quot;: &quot;nl&quot;,\n        &quot;dispatch_rule&quot;: &quot;page&quot;,\n        &quot;path_tokens&quot;: [\n            &quot;page&quot;,\n            &quot;1234&quot;,\n            &quot;hello&quot;\n        ],\n        &quot;controller_options&quot;: {\n            &quot;template&quot;: {\n                &quot;template&quot;: &quot;page.tpl&quot;,\n                &quot;is_catinclude&quot;: true\n            },\n            &quot;zotonic_dispatch_file&quot;: &quot;dispatch&quot;,\n            &quot;zotonic_dispatch_module&quot;: &quot;mod_site_whatwebwhat&quot;\n        }\n    },\n    &quot;status&quot;: &quot;ok&quot;\n}\n<\/code><\/pre>\n<h2>Creating URLs<\/h2>\n<p>URLs or page paths can also be requested using the <code>url_for<\/code> method. Here the name of the dispatch rule is padded,\noptionally with any extra arguments.<\/p>\n<p>Example:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-bash\">curl -k &#39;https:\/\/example.test:8443\/api\/model\/dispatch\/get\/url_for\/admin&#39;\n<\/code><\/pre>\n<p>Returns:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-json\">{&quot;result&quot;:&quot;\/en\/admin&quot;,&quot;status&quot;:&quot;ok&quot;}\n<\/code><\/pre>\n<p>Or, use <code>abs_url_for<\/code> if a complete URL with domain is needed:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-bash\">curl -k &#39;https:\/\/example.test:8443\/api\/model\/dispatch\/get\/abs_url_for\/admin&#39;\n<\/code><\/pre>\n<p>Returns:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-json\">{&quot;result&quot;:&quot;https:\/\/example.com\/en\/admin&quot;,&quot;status&quot;:&quot;ok&quot;}\n<\/code><\/pre>\n<p>And for more complex URLs:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-bash\">curl -k &#39;https:\/\/example.test:8443\/api\/model\/dispatch\/get\/url_for\/page?id=1234&amp;slug=foo&amp;a=1&amp;bar=baz&#39;\n<\/code><\/pre>\n<p>Returns:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-json\">{&quot;result&quot;:&quot;\/en\/page\/1234\/foo?a=1&amp;bar=baz&quot;,&quot;status&quot;:&quot;ok&quot;}\n<\/code><\/pre>\n<p>Here the selected dispatch rule was something like:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{page, [ &quot;page&quot;, id, slug ], controller_page, [ {template, &quot;page.tpl&quot;} ]}\n<\/code><\/pre>\n<p>Because <code>id<\/code> and <code>slug<\/code> are part of the path, they are included in the generated URL path, the other arguments are added\nas query parameters.<\/p>\n<h2>Available Model API Paths<\/h2>\n<table class=\"table\"><thead><tr><th>Method<\/th><th>Path pattern<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>get<\/code><\/td><td><code>\/url<\/code><\/td><td>Dispatch full URL from payload field <code>url<\/code>, returning matched rule\/controller\/options\/bindings for this site only (<code>enoent<\/code> on mismatch or no match). No further lookups.<\/td><\/tr><tr><td><code>get<\/code><\/td><td><code>\/url\/+url<\/code><\/td><td>Dispatch full URL <code>+url<\/code>, returning matched rule\/controller\/options\/bindings when it resolves to the current site; otherwise <code>enoent<\/code>. No further lookups.<\/td><\/tr><tr><td><code>get<\/code><\/td><td><code>\/path<\/code><\/td><td>Dispatch path from payload field <code>path<\/code>, returning matched rule\/controller\/options\/bindings (<code>enoent<\/code> when no rule matches). No further lookups.<\/td><\/tr><tr><td><code>get<\/code><\/td><td><code>\/path\/...<\/code><\/td><td>Dispatch supplied path segments (percent-encoded and joined) and return matched rule\/controller\/options\/bindings.<\/td><\/tr><tr><td><code>get<\/code><\/td><td><code>\/url_for\/+name\/...<\/code><\/td><td>Generate relative URL for dispatch rule <code>+name<\/code> using payload args (path vars consumed by rule, remaining args as query params); <code>enoent<\/code> when rule is unknown.<\/td><\/tr><tr><td><code>get<\/code><\/td><td><code>\/abs_url_for\/+name\/...<\/code><\/td><td>Generate absolute URL for dispatch rule <code>+name<\/code> from <code>url_for<\/code> result and current site host\/scheme; <code>enoent<\/code> when rule is unknown.<\/td><\/tr><\/tbody><\/table>\n<p><code>\/+name<\/code> marks a variable path segment. A trailing <code>\/...<\/code> means extra path segments are accepted for further lookups.<\/p>","slug":"dispatch","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"7aa8dc8c467670b271f0ddd5ff54191caa8febe05bc9ce5b4bef62737016239d","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":322,"is_a":["meta","category"],"name":"model","title":"Models","uri":"https:\/\/test.zotonic.com\/id\/322"},"doc_source_path":"apps\/zotonic_core\/src\/models\/m_dispatch.erl","publication_start":"2025-07-15T08:16:39Z","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/apps\/zotonic_core\/src\/models\/m_dispatch.erl","pivot_location_lng":null,"doc_source_kind":"model","name":"doc_model_model_dispatch","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2025-07-15T08:16:39Z","uri":null,"doc_status":"current","is_dependent":false,"erlang_app":"zotonic_core","publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"28493fb676b2d92727e68d4fba20d89c56cf8ead\n","erlang_module":"m_dispatch","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"modified":"2026-10-15T20:07:37Z","title_slug":"dispatch"},"uri":"https:\/\/zotonic.com\/id\/2437","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2437"}},"status":"ok"}