# `client.ResolveAddress()`

Resolve Address

Returns the complete address for an autocomplete suggestion, identified by its address ID.

This is the step of the autocomplete flow that costs a lookup. Fetching suggestions is free.

The API returns resolved addresses, including addresses outside the UK, in a UK format (up to 3 address lines) using UK nomenclature such as postcode and county.

An ID that matches no address returns `404`.

## Endpoint

`GET /autocomplete/addresses/{address}/gbr`

See the [API reference](/docs/api/resolve-address.md) for this endpoint.

## Signature

```go
func (c *Client) ResolveAddress(ctx context.Context, address string, params *ResolveAddressParams) (*GbrResolveAddressResponse, error)
```

## Arguments

| Name      | Type                    | Required | Description                                                                            |
| --------- | ----------------------- | -------- | -------------------------------------------------------------------------------------- |
| `ctx`     | `context.Context`       | yes      | Cancels the request and sets its deadline.                                             |
| `address` | `string`                | yes      | ID of address suggestion                                                               |
| `params`  | `*ResolveAddressParams` | no       | Optional query parameters, or nil. Fields under [Query Parameters](#query-parameters). |

## Query Parameters

A required parameter is a method argument. Set the rest as fields of `params`, named in Studly case (`post_town` is `PostTown`); a field left at its zero value is not sent.

| Name                  | Type     | Required | Description         |
| --------------------- | -------- | -------- | ------------------- |
| `tags`                | `string` | no       | Tags                |
| `remove_organisation` | `string` | no       | Remove Organisation |

## Response

`*idealpostcodes.GbrResolveAddressResponse`. Fields the API may leave out or send as null are pointers. `RawJSON()` returns the body as received. See [responses](/docs/sdks/go/responses.md).

## Errors

An HTTP error returns `*idealpostcodes.APIError` with the HTTP status, the API error code and the body; match it with `errors.AsType`. A transport failure returns the `net/http` error, wrapped. See [error handling](/docs/sdks/go/errors.md).

## Example

resolve-address/main.gogo

```go
package main

import (
	"context"
	"fmt"
	"log"

	idealpostcodes "go.ideal-postcodes.co.uk/sdk"
)

func main() {
	client := idealpostcodes.NewClient("ak_test")
	res, err := client.ResolveAddress(context.Background(), "paf_2670849", nil)
	if err != nil {
		log.Fatal(err)
	}
	address := res.Result
	fmt.Println(address.Line1)
	fmt.Printf("%s, %s\n", address.PostTown, address.Postcode)
}
```
