{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-developer-resources/ingrid-api/guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Address autocomplete","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"address-autocomplete","__idx":0},"children":["Address autocomplete"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The address search endpoint provides type-ahead suggestions as the customer"," ","types their address. It uses an expand/resolve pattern that handles"," ","hierarchical address structures — like UK streets with many buildings — while"," ","still working simply for flat address systems."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":1},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["An Ingrid API key"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["An address form rendered in your checkout (see"," ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/developer-resources/ingrid-api/guides/address-form"},"children":["rendering the address form"]},")"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"overview","__idx":2},"children":["Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The autocomplete flow follows a tree pattern. Each prediction the API returns"," ","has an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["action"]}," that tells you what to do next:"]},{"$$mdtype":"Tag","name":"Mermaid","attributes":{"data-language":"mermaid","diagramSource":"flowchart TD\n    A[Customer types in address field] --> B[GET /address/search]\n    B --> C{Check action}\n    C -->|resolve| D[GET /address/details/id]\n    D --> E[Populate form fields]\n    C -->|expand| F[GET /address/search with containerId]\n    F --> C\n","diagramHtml":"<div class=\"mermaid\" data-processed=\"true\"><svg id=\"mermaid-1770292301176\" width=\"100%\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" class=\"flowchart\" style=\"max-width: 559.234375px;\" viewBox=\"0 0 559.234375 652.84375\" role=\"graphics-document document\" aria-roledescription=\"flowchart-v2\"><style>#mermaid-1770292301176{font-family:\"trebuchet ms\",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-1770292301176 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-1770292301176 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-1770292301176 .error-icon{fill:#552222;}#mermaid-1770292301176 .error-text{fill:#552222;stroke:#552222;}#mermaid-1770292301176 .edge-thickness-normal{stroke-width:1px;}#mermaid-1770292301176 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-1770292301176 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-1770292301176 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-1770292301176 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-1770292301176 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-1770292301176 .marker{fill:#333333;stroke:#333333;}#mermaid-1770292301176 .marker.cross{stroke:#333333;}#mermaid-1770292301176 svg{font-family:\"trebuchet ms\",verdana,arial,sans-serif;font-size:16px;}#mermaid-1770292301176 p{margin:0;}#mermaid-1770292301176 .label{font-family:\"trebuchet ms\",verdana,arial,sans-serif;color:#333;}#mermaid-1770292301176 .cluster-label text{fill:#333;}#mermaid-1770292301176 .cluster-label span{color:#333;}#mermaid-1770292301176 .cluster-label span p{background-color:transparent;}#mermaid-1770292301176 .label text,#mermaid-1770292301176 span{fill:#333;color:#333;}#mermaid-1770292301176 .node rect,#mermaid-1770292301176 .node circle,#mermaid-1770292301176 .node ellipse,#mermaid-1770292301176 .node polygon,#mermaid-1770292301176 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-1770292301176 .rough-node .label text,#mermaid-1770292301176 .node .label text,#mermaid-1770292301176 .image-shape .label,#mermaid-1770292301176 .icon-shape .label{text-anchor:middle;}#mermaid-1770292301176 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-1770292301176 .rough-node .label,#mermaid-1770292301176 .node .label,#mermaid-1770292301176 .image-shape .label,#mermaid-1770292301176 .icon-shape .label{text-align:center;}#mermaid-1770292301176 .node.clickable{cursor:pointer;}#mermaid-1770292301176 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-1770292301176 .arrowheadPath{fill:#333333;}#mermaid-1770292301176 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-1770292301176 .flowchart-link{stroke:#333333;fill:none;}#mermaid-1770292301176 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-1770292301176 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-1770292301176 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-1770292301176 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-1770292301176 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-1770292301176 .cluster text{fill:#333;}#mermaid-1770292301176 .cluster span{color:#333;}#mermaid-1770292301176 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\"trebuchet ms\",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-1770292301176 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-1770292301176 rect.text{fill:none;stroke-width:0;}#mermaid-1770292301176 .icon-shape,#mermaid-1770292301176 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-1770292301176 .icon-shape p,#mermaid-1770292301176 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-1770292301176 .icon-shape rect,#mermaid-1770292301176 .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-1770292301176 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-1770292301176 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-1770292301176 :root{--mermaid-font-family:\"trebuchet ms\",verdana,arial,sans-serif;}</style><g><marker id=\"mermaid-1770292301176_flowchart-v2-pointEnd\" class=\"marker flowchart-v2\" viewBox=\"0 0 10 10\" refX=\"5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 0 L 10 5 L 0 10 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"></path></marker><marker id=\"mermaid-1770292301176_flowchart-v2-pointStart\" class=\"marker flowchart-v2\" viewBox=\"0 0 10 10\" refX=\"4.5\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"8\" markerHeight=\"8\" orient=\"auto\"><path d=\"M 0 5 L 10 10 L 10 0 z\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"></path></marker><marker id=\"mermaid-1770292301176_flowchart-v2-circleEnd\" class=\"marker flowchart-v2\" viewBox=\"0 0 10 10\" refX=\"11\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"11\" markerHeight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"></circle></marker><marker id=\"mermaid-1770292301176_flowchart-v2-circleStart\" class=\"marker flowchart-v2\" viewBox=\"0 0 10 10\" refX=\"-1\" refY=\"5\" markerUnits=\"userSpaceOnUse\" markerWidth=\"11\" markerHeight=\"11\" orient=\"auto\"><circle cx=\"5\" cy=\"5\" r=\"5\" class=\"arrowMarkerPath\" style=\"stroke-width: 1; stroke-dasharray: 1, 0;\"></circle></marker><marker id=\"mermaid-1770292301176_flowchart-v2-crossEnd\" class=\"marker cross flowchart-v2\" viewBox=\"0 0 11 11\" refX=\"12\" refY=\"5.2\" markerUnits=\"userSpaceOnUse\" markerWidth=\"11\" markerHeight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"></path></marker><marker id=\"mermaid-1770292301176_flowchart-v2-crossStart\" class=\"marker cross flowchart-v2\" viewBox=\"0 0 11 11\" refX=\"-1\" refY=\"5.2\" markerUnits=\"userSpaceOnUse\" markerWidth=\"11\" markerHeight=\"11\" orient=\"auto\"><path d=\"M 1,1 l 9,9 M 10,1 l -9,9\" class=\"arrowMarkerPath\" style=\"stroke-width: 2; stroke-dasharray: 1, 0;\"></path></marker><g class=\"root\"><g class=\"clusters\"></g><g class=\"edgePaths\"><path d=\"M310.285,86L310.285,90.167C310.285,94.333,310.285,102.667,310.285,110.333C310.285,118,310.285,125,310.285,128.5L310.285,132\" id=\"L_A_B_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_A_B_0\" data-points=\"W3sieCI6MzEwLjI4NTE1NjI1LCJ5Ijo4Nn0seyJ4IjozMTAuMjg1MTU2MjUsInkiOjExMX0seyJ4IjozMTAuMjg1MTU2MjUsInkiOjEzNn1d\" marker-end=\"url(#mermaid-1770292301176_flowchart-v2-pointEnd)\"></path><path d=\"M310.285,190L310.285,194.167C310.285,198.333,310.285,206.667,310.285,214.333C310.285,222,310.285,229,310.285,232.5L310.285,236\" id=\"L_B_C_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_B_C_0\" data-points=\"W3sieCI6MzEwLjI4NTE1NjI1LCJ5IjoxOTB9LHsieCI6MzEwLjI4NTE1NjI1LCJ5IjoyMTV9LHsieCI6MzEwLjI4NTE1NjI1LCJ5IjoyNDB9XQ==\" marker-end=\"url(#mermaid-1770292301176_flowchart-v2-pointEnd)\"></path><path d=\"M263.775,342.333L240.582,356.252C217.389,370.17,171.003,398.007,147.81,419.425C124.617,440.844,124.617,455.844,124.617,463.344L124.617,470.844\" id=\"L_C_D_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_D_0\" data-points=\"W3sieCI6MjYzLjc3NDc4NjkwMzgwMzE1LCJ5IjozNDIuMzMzMzgwNjUzODAzMTV9LHsieCI6MTI0LjYxNzE4NzUsInkiOjQyNS44NDM3NX0seyJ4IjoxMjQuNjE3MTg3NSwieSI6NDc0Ljg0Mzc1fV0=\" marker-end=\"url(#mermaid-1770292301176_flowchart-v2-pointEnd)\"></path><path d=\"M124.617,528.844L124.617,535.01C124.617,541.177,124.617,553.51,124.617,563.177C124.617,572.844,124.617,579.844,124.617,583.344L124.617,586.844\" id=\"L_D_E_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_D_E_0\" data-points=\"W3sieCI6MTI0LjYxNzE4NzUsInkiOjUyOC44NDM3NX0seyJ4IjoxMjQuNjE3MTg3NSwieSI6NTY1Ljg0Mzc1fSx7IngiOjEyNC42MTcxODc1LCJ5Ijo1OTAuODQzNzV9XQ==\" marker-end=\"url(#mermaid-1770292301176_flowchart-v2-pointEnd)\"></path><path d=\"M310.285,388.844L310.285,395.01C310.285,401.177,310.285,413.51,318.738,425.467C327.19,437.424,344.095,449.003,352.547,454.793L361,460.583\" id=\"L_C_F_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_C_F_0\" data-points=\"W3sieCI6MzEwLjI4NTE1NjI1LCJ5IjozODguODQzNzV9LHsieCI6MzEwLjI4NTE1NjI1LCJ5Ijo0MjUuODQzNzV9LHsieCI6MzY0LjI5OTkwNzQ4MzU1MjYsInkiOjQ2Mi44NDM3NX1d\" marker-end=\"url(#mermaid-1770292301176_flowchart-v2-pointEnd)\"></path><path d=\"M433.504,462.844L435.444,456.677C437.384,450.51,441.264,438.177,428.034,419.476C414.803,400.776,384.462,375.707,369.292,363.173L354.121,350.639\" id=\"L_F_C_0\" class=\"edge-thickness-normal edge-pattern-solid edge-thickness-normal edge-pattern-solid flowchart-link\" style=\";\" data-edge=\"true\" data-et=\"edge\" data-id=\"L_F_C_0\" data-points=\"W3sieCI6NDMzLjUwNDA2MDQ0NDA3ODk2LCJ5Ijo0NjIuODQzNzV9LHsieCI6NDQ1LjE0NDUzMTI1LCJ5Ijo0MjUuODQzNzV9LHsieCI6MzUxLjAzNzI5NDUwMTgwODE2LCJ5IjozNDguMDkxNjExNzQ4MTkxODR9XQ==\" marker-end=\"url(#mermaid-1770292301176_flowchart-v2-pointEnd)\"></path></g><g class=\"edgeLabels\"><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_A_B_0\" transform=\"translate(0, 0)\"><foreignObject width=\"0\" height=\"0\"><div xmlns=\"http://www.w3.org/1999/xhtml\" class=\"labelBkg\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"edgeLabel\"></span></div></foreignObject></g></g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_B_C_0\" transform=\"translate(0, 0)\"><foreignObject width=\"0\" height=\"0\"><div xmlns=\"http://www.w3.org/1999/xhtml\" class=\"labelBkg\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"edgeLabel\"></span></div></foreignObject></g></g><g class=\"edgeLabel\" transform=\"translate(124.6171875, 425.84375)\"><g class=\"label\" data-id=\"L_C_D_0\" transform=\"translate(-26.8984375, -12)\"><foreignObject width=\"53.796875\" height=\"24\"><div xmlns=\"http://www.w3.org/1999/xhtml\" class=\"labelBkg\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"edgeLabel\"><p>resolve</p></span></div></foreignObject></g></g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_D_E_0\" transform=\"translate(0, 0)\"><foreignObject width=\"0\" height=\"0\"><div xmlns=\"http://www.w3.org/1999/xhtml\" class=\"labelBkg\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"edgeLabel\"></span></div></foreignObject></g></g><g class=\"edgeLabel\" transform=\"translate(310.28515625, 425.84375)\"><g class=\"label\" data-id=\"L_C_F_0\" transform=\"translate(-27.8203125, -12)\"><foreignObject width=\"55.640625\" height=\"24\"><div xmlns=\"http://www.w3.org/1999/xhtml\" class=\"labelBkg\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"edgeLabel\"><p>expand</p></span></div></foreignObject></g></g><g class=\"edgeLabel\"><g class=\"label\" data-id=\"L_F_C_0\" transform=\"translate(0, 0)\"><foreignObject width=\"0\" height=\"0\"><div xmlns=\"http://www.w3.org/1999/xhtml\" class=\"labelBkg\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"edgeLabel\"></span></div></foreignObject></g></g></g><g class=\"nodes\"><g class=\"node default\" id=\"flowchart-A-0\" transform=\"translate(310.28515625, 47)\"><rect class=\"basic label-container\" style=\"\" x=\"-130\" y=\"-39\" width=\"260\" height=\"78\"></rect><g class=\"label\" style=\"\" transform=\"translate(-100, -24)\"><rect></rect><foreignObject width=\"200\" height=\"48\"><div xmlns=\"http://www.w3.org/1999/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><p>Customer types in address field</p></span></div></foreignObject></g></g><g class=\"node default\" id=\"flowchart-B-1\" transform=\"translate(310.28515625, 163)\"><rect class=\"basic label-container\" style=\"\" x=\"-106.9921875\" y=\"-27\" width=\"213.984375\" height=\"54\"></rect><g class=\"label\" style=\"\" transform=\"translate(-76.9921875, -12)\"><rect></rect><foreignObject width=\"153.984375\" height=\"24\"><div xmlns=\"http://www.w3.org/1999/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><p>GET /address/search</p></span></div></foreignObject></g></g><g class=\"node default\" id=\"flowchart-C-3\" transform=\"translate(310.28515625, 314.421875)\"><polygon points=\"74.421875,0 148.84375,-74.421875 74.421875,-148.84375 0,-74.421875\" class=\"label-container\" transform=\"translate(-73.921875, 74.421875)\"></polygon><g class=\"label\" style=\"\" transform=\"translate(-47.421875, -12)\"><rect></rect><foreignObject width=\"94.84375\" height=\"24\"><div xmlns=\"http://www.w3.org/1999/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><p>Check action</p></span></div></foreignObject></g></g><g class=\"node default\" id=\"flowchart-D-5\" transform=\"translate(124.6171875, 501.84375)\"><rect class=\"basic label-container\" style=\"\" x=\"-116.6171875\" y=\"-27\" width=\"233.234375\" height=\"54\"></rect><g class=\"label\" style=\"\" transform=\"translate(-86.6171875, -12)\"><rect></rect><foreignObject width=\"173.234375\" height=\"24\"><div xmlns=\"http://www.w3.org/1999/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><p>GET /address/details/id</p></span></div></foreignObject></g></g><g class=\"node default\" id=\"flowchart-E-7\" transform=\"translate(124.6171875, 617.84375)\"><rect class=\"basic label-container\" style=\"\" x=\"-105.5\" y=\"-27\" width=\"211\" height=\"54\"></rect><g class=\"label\" style=\"\" transform=\"translate(-75.5, -12)\"><rect></rect><foreignObject width=\"151\" height=\"24\"><div xmlns=\"http://www.w3.org/1999/xhtml\" style=\"display: table-cell; white-space: nowrap; line-height: 1.5; max-width: 200px; text-align: center;\"><span class=\"nodeLabel\"><p>Populate form fields</p></span></div></foreignObject></g></g><g class=\"node default\" id=\"flowchart-F-9\" transform=\"translate(421.234375, 501.84375)\"><rect class=\"basic label-container\" style=\"\" x=\"-130\" y=\"-39\" width=\"260\" height=\"78\"></rect><g class=\"label\" style=\"\" transform=\"translate(-100, -24)\"><rect></rect><foreignObject width=\"200\" height=\"48\"><div xmlns=\"http://www.w3.org/1999/xhtml\" style=\"display: table; white-space: break-spaces; line-height: 1.5; max-width: 200px; text-align: center; width: 200px;\"><span class=\"nodeLabel\"><p>GET /address/search with containerId</p></span></div></foreignObject></g></g></g></g></g></svg></div>"},"children":["flowchart TD\n    A[Customer types in address field] --> B[GET /address/search]\n    B --> C{Check action}\n    C -->|resolve| D[GET /address/details/id]\n    D --> E[Populate form fields]\n    C -->|expand| F[GET /address/search with containerId]\n    F --> C\n"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resolve"]}]}," — this prediction is a specific address. Call the details"," ","endpoint to get the full ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DeliveryAddress"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["expand"]}]}," — this prediction is a container (a street, a building, a postal"," ","code area). Call search again with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["containerId"]}," to drill down into it."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-1-search-for-addresses","__idx":3},"children":["Step 1: Search for addresses"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["As the customer types, send their input to the search endpoint:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"Request","header":{"title":"Request","controls":{"copy":{}}},"source":"curl -X GET \"https://api.ingrid.com/v1/delivery/address/search?countryCode=GB&query=10%20Bucking\" \\\n  -H \"Authorization: Bearer <YOUR_API_KEY>\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"Response","header":{"title":"Response","controls":{"copy":{}}},"source":"{\n  \"predictions\": [\n    {\n      \"id\": \"addr_gbr_10045832\",\n      \"label\": \"10 Buckingham Road\",\n      \"secondaryLabel\": \"Redcar, TS10 3JQ\",\n      \"action\": \"resolve\",\n      \"type\": \"streetAddress\"\n    },\n    {\n      \"id\": \"grp_street_882\",\n      \"label\": \"10 Buckingham Street\",\n      \"secondaryLabel\": \"3 addresses\",\n      \"action\": \"expand\",\n      \"count\": 3,\n      \"type\": \"street\"\n    },\n    {\n      \"id\": \"addr_gbr_20091744\",\n      \"label\": \"10 Buckingham Gate\",\n      \"secondaryLabel\": \"London, SW1E 6LB\",\n      \"action\": \"resolve\",\n      \"type\": \"streetAddress\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Display the predictions as a dropdown list. Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["label"]}," as the primary text"," ","and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["secondaryLabel"]}," as secondary context. The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["type"]}," field can be used to"," ","select an icon (street, building, postal code, etc.)."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-2-handle-the-action","__idx":4},"children":["Step 2: Handle the action"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When the customer selects a prediction, check its ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["action"]},":"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"if-action-is-resolve","__idx":5},"children":["If ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["action"]}," is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resolve"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The prediction is a specific address. Proceed to ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#step-3-resolve-to-full-address"},"children":["Step 3"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"if-action-is-expand","__idx":6},"children":["If ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["action"]}," is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["expand"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The prediction is a container with child addresses. Call search again with the"," ","prediction's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}," as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["containerId"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"Request","header":{"title":"Request","controls":{"copy":{}}},"source":"curl -X GET \"https://api.ingrid.com/v1/delivery/address/search?countryCode=GB&containerId=grp_street_882\" \\\n  -H \"Authorization: Bearer <YOUR_API_KEY>\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"Response","header":{"title":"Response","controls":{"copy":{}}},"source":"{\n  \"predictions\": [\n    {\n      \"id\": \"addr_gbr_30012001\",\n      \"label\": \"Flat 1, 10 Buckingham Street\",\n      \"secondaryLabel\": \"London, WC2N 6DF\",\n      \"action\": \"resolve\",\n      \"type\": \"premise\"\n    },\n    {\n      \"id\": \"addr_gbr_30012002\",\n      \"label\": \"Flat 2, 10 Buckingham Street\",\n      \"secondaryLabel\": \"London, WC2N 6DF\",\n      \"action\": \"resolve\",\n      \"type\": \"premise\"\n    },\n    {\n      \"id\": \"addr_gbr_30012003\",\n      \"label\": \"Flat 3, 10 Buckingham Street\",\n      \"secondaryLabel\": \"London, WC2N 6DF\",\n      \"action\": \"resolve\",\n      \"type\": \"premise\"\n    }\n  ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Display the new predictions. The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["count"]}," field on the parent prediction tells"," ","you how many children to expect, which you can use to show \"3 addresses\" in"," ","the UI before expanding."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Expanding can be recursive — a container may contain more containers — but in"," ","practice most lookups resolve within one or two levels."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-3-resolve-to-full-address","__idx":7},"children":["Step 3: Resolve to full address"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When the customer selects a prediction with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["action: \"resolve\""]},", call the"," ","details endpoint with its ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"Request","header":{"title":"Request","controls":{"copy":{}}},"source":"curl -X GET \"https://api.ingrid.com/v1/delivery/address/details/addr_gbr_10045832\" \\\n  -H \"Authorization: Bearer <YOUR_API_KEY>\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","data-title":"Response","header":{"title":"Response","controls":{"copy":{}}},"source":"{\n  \"deliveryAddress\": {\n    \"countryCode\": \"GB\",\n    \"postalCode\": \"TS10 3JQ\",\n    \"addressLines\": [\"10 Buckingham Road\"],\n    \"locality\": \"Redcar\"\n  }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-4-populate-the-form","__idx":8},"children":["Step 4: Populate the form"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Map the returned ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["DeliveryAddress"]}," fields to your form inputs. The field names"," ","in the response match the field names from the"," ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/developer-resources/ingrid-api/guides/address-form"},"children":["form endpoint"]},", so the mapping is direct."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["After populating, allow the customer to review and edit the pre-filled values"," ","before proceeding."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"the-focus-parameter","__idx":9},"children":["The focus parameter"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The optional ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["focus"]}," parameter scopes autocomplete behavior to a specific form"," ","field. This is useful when the customer is editing an individual field rather"," ","than typing a full address:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"focus value"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["focus"]}," value"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Behavior"},"children":["Behavior"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["addressLines"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Search street addresses (default behavior)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["postalCode"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Search by postal code. Useful for postal code lookups (PAF-style)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["locality"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Search city or town names"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["administrativeArea"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Search states, provinces, or regions"]}]}]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","data-title":"Example: postal code focused search","header":{"title":"Example: postal code focused search","controls":{"copy":{}}},"source":"curl -X GET \"https://api.ingrid.com/v1/delivery/address/search?countryCode=GB&query=SW1A&focus=postalCode\" \\\n  -H \"Authorization: Bearer <YOUR_API_KEY>\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"debouncing-and-performance","__idx":10},"children":["Debouncing and performance"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The search endpoint is designed for real-time use, but you should still"," ","debounce requests on the client side. A 200-300ms debounce after the last"," ","keystroke prevents excessive API calls without hurting perceived responsiveness."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Do not call search with fewer than 2-3 characters — the results will be too"," ","broad to be useful."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"error-handling","__idx":11},"children":["Error handling"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Error"},"children":["Error"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"When it occurs"},"children":["When it occurs"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["400 Bad Request"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Invalid or missing ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["countryCode"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["404 Not Found"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}," passed to the details endpoint does not exist or has expired"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["500 Internal Server Error"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Server-side issue — retry with exponential backoff"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Prediction IDs are opaque and may expire. If a details call returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["404"]},","," ","prompt the customer to search again."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"next-steps","__idx":12},"children":["Next steps"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/developer-resources/ingrid-api/guides/address-validation"},"children":["Address validation"]}," — verify the resolved address"," ","before creating an order"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/developer-resources/ingrid-api/guides/country-reference"},"children":["Country reference"]}," — country-specific"," ","addressing rules"]}]}]},"headings":[{"value":"Address autocomplete","id":"address-autocomplete","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Overview","id":"overview","depth":2},{"value":"Step 1: Search for addresses","id":"step-1-search-for-addresses","depth":2},{"value":"Step 2: Handle the action","id":"step-2-handle-the-action","depth":2},{"value":"If action is resolve","id":"if-action-is-resolve","depth":3},{"value":"If action is expand","id":"if-action-is-expand","depth":3},{"value":"Step 3: Resolve to full address","id":"step-3-resolve-to-full-address","depth":2},{"value":"Step 4: Populate the form","id":"step-4-populate-the-form","depth":2},{"value":"The focus parameter","id":"the-focus-parameter","depth":2},{"value":"Debouncing and performance","id":"debouncing-and-performance","depth":2},{"value":"Error handling","id":"error-handling","depth":2},{"value":"Next steps","id":"next-steps","depth":2}],"frontmatter":{"title":"Address Autocomplete","description":"How to add type-ahead address search to your checkout using the expand and resolve pattern","seo":{"title":"Address autocomplete"}},"lastModified":"2026-02-24T19:14:57.409Z","pagePropGetterError":{"message":"","name":""}},"slug":"/developer-resources/ingrid-api/guides/address-autocomplete","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}