diff --git a/HISTORY.rst b/HISTORY.rst
index 2073fb4..dda2242 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -6,6 +6,10 @@ Pending Release
 
 .. Insert new release notes below this line
 
+* Change ``statusCode`` returned to API Gateway / ALB to an integer. It seems
+  API Gateway always supported both strings and integers, whilst API Gateway
+  only supports integers.
+
 2.0.2 (2019-02-07)
 ------------------
 
diff --git a/apig_wsgi.py b/apig_wsgi.py
index 3a1045b..cb204c3 100644
--- a/apig_wsgi.py
+++ b/apig_wsgi.py
@@ -72,7 +72,7 @@ def get_environ(event, binary_support):
 
 class Response(object):
     def __init__(self, binary_support):
-        self.status_code = '500'
+        self.status_code = 500
         self.headers = []
         self.body = BytesIO()
         self.binary_support = binary_support
@@ -80,7 +80,7 @@ class Response(object):
     def start_response(self, status, response_headers, exc_info=None):
         if exc_info is not None:
             raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
-        self.status_code = status.split()[0]
+        self.status_code = int(status.split()[0])
         self.headers.extend(response_headers)
         return self.body.write
 

502 bad gateway error on ALB : statusCode must be numeric
Hey,

having an issue with apig-wsgi on an ALB : I always receive a 502 bad gateway error.
Changing statusCode from a string to a number solve my issue.

This is my working monkey patching :

import apig_wsgi
class Response(apig_wsgi.Response):
    def as_apig_response(self):
        response = super().as_apig_response()
        response['statusCode'] = int(response['statusCode'])
        return response
apig_wsgi.Response = Response

diff --git a/test_apig_wsgi.py b/test_apig_wsgi.py
index 6d61584..341bc6a 100644
--- a/test_apig_wsgi.py
+++ b/test_apig_wsgi.py
@@ -45,7 +45,7 @@ def test_get(simple_app):
     response = simple_app.handler(make_event(), None)
 
     assert response == {
-        'statusCode': '200',
+        'statusCode': 200,
         'headers': {'Content-Type': 'text/plain'},
         'body': 'Hello World\n',
     }
@@ -57,7 +57,7 @@ def test_get_missing_content_type(simple_app):
     response = simple_app.handler(make_event(), None)
 
     assert response == {
-        'statusCode': '200',
+        'statusCode': 200,
         'headers': {},
         'body': 'Hello World\n',
     }
@@ -69,7 +69,7 @@ def test_get_binary_support_text(simple_app):
     response = simple_app.handler(make_event(), None)
 
     assert response == {
-        'statusCode': '200',
+        'statusCode': 200,
         'headers': {'Content-Type': 'text/plain'},
         'body': 'Hello World\n',
     }
@@ -83,7 +83,7 @@ def test_get_binary_support_binary(simple_app):
     response = simple_app.handler(make_event(), None)
 
     assert response == {
-        'statusCode': '200',
+        'statusCode': 200,
         'headers': {'Content-Type': 'application/octet-stream'},
         'body': b64encode(b'\x13\x37').decode('utf-8'),
         'isBase64Encoded': True,
@@ -98,7 +98,7 @@ def test_get_binary_support_no_content_type(simple_app):
     response = simple_app.handler(make_event(), None)
 
     assert response == {
-        'statusCode': '200',
+        'statusCode': 200,
         'headers': {},
         'body': b64encode(b'\x13\x37').decode('utf-8'),
         'isBase64Encoded': True,
@@ -113,7 +113,7 @@ def test_post(simple_app):
     assert simple_app.environ['wsgi.input'].read() == b'The World is Large'
     assert simple_app.environ['CONTENT_LENGTH'] == str(len(b'The World is Large'))
     assert response == {
-        'statusCode': '200',
+        'statusCode': 200,
         'headers': {'Content-Type': 'text/plain'},
         'body': 'Hello World\n',
     }
@@ -128,7 +128,7 @@ def test_post_binary_support(simple_app):
     assert simple_app.environ['wsgi.input'].read() == b'dogfood'
     assert simple_app.environ['CONTENT_LENGTH'] == str(len(b'dogfood'))
     assert response == {
-        'statusCode': '200',
+        'statusCode': 200,
         'headers': {'Content-Type': 'text/plain'},
         'body': 'Hello World\n',
     }

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
-e git+https://github.com/adamchainz/apig-wsgi.git@9bd886d2bda1407cc334b376e967be27025d211d#egg=apig_wsgi
atomicwrites==1.3.0
attrs==19.1.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
coverage==4.5.3
docutils==0.14
entrypoints==0.3
exceptiongroup==1.2.2
execnet==2.0.2
flake8==3.7.7
flake8-commas==2.0.0
importlib-metadata==6.7.0
iniconfig==2.0.0
isort==4.3.15
mccabe==0.6.1
more-itertools==6.0.0
multilint==2.4.0
packaging==24.0
pluggy==1.2.0
py==1.8.0
pycodestyle==2.5.0
pyflakes==2.1.1
Pygments==2.3.1
pytest==7.4.4
pytest-asyncio==0.21.2
pytest-cov==2.6.1
pytest-mock==3.11.1
pytest-xdist==3.5.0
six==1.12.0
tomli==2.0.1
typing_extensions==4.7.1
zipp==3.15.0

name: apig-wsgi
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - atomicwrites==1.3.0
      - attrs==19.1.0
      - coverage==4.5.3
      - docutils==0.14
      - entrypoints==0.3
      - exceptiongroup==1.2.2
      - execnet==2.0.2
      - flake8==3.7.7
      - flake8-commas==2.0.0
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - isort==4.3.15
      - mccabe==0.6.1
      - more-itertools==6.0.0
      - multilint==2.4.0
      - packaging==24.0
      - pluggy==1.2.0
      - py==1.8.0
      - pycodestyle==2.5.0
      - pyflakes==2.1.1
      - pygments==2.3.1
      - pytest==7.4.4
      - pytest-asyncio==0.21.2
      - pytest-cov==2.6.1
      - pytest-mock==3.11.1
      - pytest-xdist==3.5.0
      - six==1.12.0
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - zipp==3.15.0
prefix: /opt/conda/envs/apig-wsgi

test_apig_wsgi.py::test_get test_apig_wsgi.py::test_get_missing_content_type test_apig_wsgi.py::test_get_binary_support_text test_apig_wsgi.py::test_get_binary_support_binary test_apig_wsgi.py::test_get_binary_support_no_content_type test_apig_wsgi.py::test_post test_apig_wsgi.py::test_post_binary_support
test_apig_wsgi.py::test_querystring_none test_apig_wsgi.py::test_querystring_empty test_apig_wsgi.py::test_querystring_one test_apig_wsgi.py::test_plain_header test_apig_wsgi.py::test_special_headers test_apig_wsgi.py::test_no_headers test_apig_wsgi.py::test_headers_None test_apig_wsgi.py::test_exc_info
HISTORY.rst apig_wsgi.py
HISTORY.rst apig_wsgi.py